du

Estimate disk usage of files and directories.

low risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
What it does

du walks the directory tree summing file sizes. -s gives a total for each argument. --max-depth limits recursion depth. Piping to `sort -rh` reveals the biggest disk consumers — essential for tracking down space hogs.

Common flags
FlagMeaning
-h --human-readablePrint sizes in human-readable format
-s --summarizeDisplay only a total for each argument
-a --allInclude all files, not just directories
--max-depthLimit directory recursion depth
--excludeExclude files matching a pattern
Examples
du -sh /var/log/*Show size of each item in /var/log · explain & risk-check →
du -h --max-depth=2 / | sort -rh | head -20Find top 20 largest directories from root · explain & risk-check →
du -sh --exclude='.git' .Get total size of current directory excluding .git · explain & risk-check →
Pro tip

Install `ncdu` for an interactive disk usage explorer: `sudo apt install ncdu && ncdu /`

Related
df ncdu find ls
Open the full explainer →More in Files & Archives

Reference text is hand-written and may be incomplete — check man du for your version. Test destructive commands on a non-production system first.