Find which subdirectories use the most disk space with du

Measure the size of each immediate subdirectory and sort them smallest to largest so the biggest offenders land at the bottom.

LinuxFilesDiagnosticsLow risk
Run du -h --max-depth=1 . | sort -h in the directory you want to analyze to list each subdirectory's size, largest last.

01Command

Command
$ du -h --max-depth=1 . | sort -h

02What it does

du walks the tree and sums file sizes; --max-depth=1 reports each child directory as one total instead of every nested path. sort -h understands the K/M/G suffixes du prints, so sizes order correctly. Start at /var, /home, or / and drill down by repeating the command inside the largest directory. Add sudo to count files you cannot read, use -x to stay on one filesystem (skip /proc and other mounts), and note du counts allocated blocks, so sparse files can appear larger than they are.

03Risk

RiskLow risk
!Warning: Running du on very large trees (like all of /) takes a while and hammers the disk — use ncdu for an interactive alternative on slow systems.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • du(1) — estimate file space usage
    man7.org · technical · 2026-09-17
    Evidence: The du man page documents '--max-depth=N' to limit the depth of directory reporting and '-h' for human-readable sizes.

Last verified: 2026-09-17 · Category: Files & Folders

06Related solutions