Back to commands

Linux Survival Basics

Read-only

Find 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

Linux Survival Basics Can be slow

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
Linux Survival Basics Read-only

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
Linux Survival Basics Can be slow

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
Linux Survival Basics Read-only

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$/'
Linux Survival Basics Can be slow

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.

  • LPIC-1 style command-line practice
  • LFCS style performance-task practice
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.