du Show how much disk space files and folders use
Reports the disk space used by files and by the folders that contain them. Use it to find out what is eating your disk. Unlike df, which reports on a whole disk, du measures specific folders.
Synopsis
du [OPTION]... [FILE]...
du -sh DIRECTORY
Common options
| Option or form | What it does |
|---|---|
-h | Human-readable sizes such as 4.0K, 12M or 1.3G |
-s | Summary: print one total for each argument instead of every sub-folder |
-d N | Show totals only down to N levels deep. -d 1 shows each item directly inside a folder. GNU/Linux also spells it --max-depth=N |
-a | Show files as well as folders. By default only folders get a line |
-c | Add a grand total line at the end |
-k | Report sizes in 1024-byte blocks (kilobytes) |
-x | Stay on one filesystem. Do not descend into other mounted disks |
-L | Follow symbolic links and count what they point to. By default links are counted as links |
Examples
du -sh docs
du -h -d 1 .
du -ah docs
du -ch notes.txt app.log data.csv
du -h -d 1 . | sort -rh | head -5
du -h -d 1 ~ | sort -rh | head -10
Notes
- The depth flag differs. macOS uses -d N. GNU/Linux uses --max-depth=N, and recent GNU versions also accept -d N. On an older Linux system, use --max-depth.
- du reports disk usage, which is rounded up to whole blocks, so a 1-byte file can show as 4.0K. To see the byte size instead, use -A on macOS or --apparent-size on GNU/Linux.
- sort -h understands sizes like 4.0K and 1.2G, so du -h -d 1 | sort -h gives a correct order. Plain sort -n on human-readable sizes puts them in the wrong order.
- Without -h, the unit is not the same everywhere. macOS counts 512-byte blocks by default and GNU/Linux counts 1024-byte blocks. Add -k when you want the same result on both.
- du can be slow on big folders, and it prints permission errors for folders you cannot read. Add 2>/dev/null to hide those messages.
See also
Last reviewed 2026-10-07.