Find the Biggest Files With du and sort
Rank files and folders by size using a human-readable sort.
Run du -ah . | sort -rh | head -20 to list the twenty largest entries.
01Command
Command
$ du -ah . | sort -rh | head -2002What it does
du prints sizes for every file and directory, sort -h orders human-readable units correctly and head trims the list, giving an instant space audit. This composable pipeline is a textbook reason to use the shell for filesystem analysis.
03Risk
!Warning: Traversing huge trees can take time and cross mount points; add -x to stay on one filesystem.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- du.1.en.html manual page (Debian bookworm)Evidence: Documents du -a and -h for per-file sizes.
- sort.1.en.html manual page (Debian bookworm)Evidence: Documents sort -h for human-readable numeric sorting.
Last verified: 2026-10-13 · Category: Files & Folders
06Related solutions
Search text recursively in a directory with grep
Find every occurrence of a pattern across all files in a tree, printed as file:line:number matches.
Extract a .tar.gz archive with tar
Unpack a gzipped tarball into the current directory while printing each file as it is extracted.
Check free disk space on each filesystem with df
Show total, used, and available space plus usage percentage for every mounted filesystem in human-readable units.