Linux Survival Basics
Read-onlyFind the Largest Installed Packages
A Debian or Ubuntu system is low on disk and you need to see which installed packages occupy the most space.
Command
dpkg-query -W -f='${Installed-Size}\t${Package}\n' | sort -nr | head -20
Before you run this
System impact: Read-only. Low when scoped to the shown target.
When not to use it: Do not remove large packages just because they are large; kernels, runtimes, and databases may be required.
Expected output
A size-sorted list of installed packages by KiB.
System impact
Read-only. Nothing changes. dpkg-query prints installed package sizes from metadata and sorts the largest first.
Recovery / rollback: no state is changed.
When to use it
Use before cleanup conversations, image slimming, or deciding which package families deserve review.
When not to use it
Do not remove large packages just because they are large; kernels, runtimes, and databases may be required.
next steps
Related commands
Find the Files Eating Your Disk
The disk was full, but guessing at folders was the slow part.
find /var -type f -printf '%s %p\n' | sort -nr | head -20
List Installed Package Versions
A package inventory beats memory when a server is drifting.
dpkg-query -W -f='${Package}\t${Version}\t${Architecture}\n' | sort
Count Failures by Test File
Turn noisy test logs into a ranked failure list.
grep -RhoE '[A-Za-z0-9_./-]+\.(test|spec)\.(js|ts|py|rb)' logs/ | sort | uniq -c | sort -nr | head
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$/'
Find the Largest CI Logs
Huge logs often point to loops, noisy tests, or runaway debug output.
find logs/ -type f -printf '%s %p\n' | sort -nr | head -10
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.