Linux Survival Basics
Read-onlyList Installed Package Versions
You need a deterministic list of installed Debian packages, versions, and architectures for comparison or incident notes.
Command
dpkg-query -W -f='${Package}\t${Version}\t${Architecture}\n' | sort
Before you run this
System impact: Read-only. Low when scoped to the shown target.
When not to use it: Do not use it to discover available updates; use apt list --upgradable for candidate upgrades.
Expected output
Sorted package, version, and architecture rows.
System impact
Read-only. Nothing changes. dpkg-query reads the local package database and prints a sorted inventory.
Recovery / rollback: no state is changed.
When to use it
Use before upgrades, after incidents, during fleet comparison, or when handing a host to another operator.
When not to use it
Do not use it to discover available updates; use apt list --upgradable for candidate upgrades.
next steps
Related commands
Find the Largest Installed Packages
Disk cleanup starts with evidence, not random package removal.
dpkg-query -W -f='${Installed-Size}\t${Package}\n' | sort -nr | head -20
Spot Foreign-Architecture Packages
One unexpected architecture can explain confusing dependency output.
dpkg-query -W -f='${Architecture}\t${Package}\n' | awk '$1 != "amd64" && $1 != "all"'
Find Broken or Leftover dpkg States
Not every package row is cleanly installed.
dpkg-query -W -f='${db:Status-Abbrev}\t${Package}\n' | awk '$1 !~ /^ii$/'
Check One Installed Package Cleanly
For one package, dpkg-query gives a clean status line.
dpkg-query -W -f='${Status} ${Version}\n' openssl
See Which Packages Want Updates
Before you upgrade anything, list what would move.
apt list --upgradable
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.