Linux Survival Basics
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
What changed
Nothing changes. dpkg-query prints installed package sizes from metadata and sorts the largest first.
Danger
safe
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.
Undo or recovery
No undo needed because the command is read-only.
Expected output
A size-sorted list of installed packages by KiB.
demo script
Disposable terminal steps
dpkg-query -W -f='${Installed-Size}\t${Package}\n' | sort -nr | head -20dpkg-query -W -f='${Installed-Size}\t${Package}\n' | sort -nr | head -5
simulated output
What it looks like
::fixture-ready::
$ dpkg-query -W -f='${Installed-Size}\t${Package}\n' | sort -nr | head -20
132904 linux-image-6.8.0-60-generic
52288 python3
18320 nginx
8420 openssl
7488 curl
7240 libc6
6800 bash
980 base-files
256 zlib1g
250 zlib1g:i386
::exit-code::0
$ dpkg-query -W -f='${Installed-Size}\t${Package}\n' | sort -nr | head -5
132904 linux-image-6.8.0-60-generic
52288 python3
18320 nginx
8420 openssl
7488 curl
::exit-code::0
YouTube Short
Find big packages.
Before removing random packages, sort installed package sizes. Cleanup becomes evidence instead of guesswork.
LinkedIn hook
Disk cleanup starts with evidence, not random package removal.
Question: Do package sizes matter in your disk cleanup checklist?
experiments
A/B tests to run
Metric: save_rate
A: Disk cleanup with evidence.
B: Which packages are largest?