du: show disk usage of files and directories

Updated November 2026

du adds up how much disk space files and directories use. When a disk is full, df tells you which file system, and du tells you which directories are responsible.

du [options] [file or directory ...]

Common options

OptionMeaning
-hHuman-readable sizes (K, M, G)
-sOnly a total for each argument
-d N, --max-depth=NShow directories only N levels deep
-xStay on one file system
-aShow files as well as directories
-cPrint a grand total
--exclude=PATTERNSkip matching files (GNU)

Examples

du -sh /var/log                      # total size of one directory
du -sh *                             # size of everything in the current directory
du -h -d 1 /var | sort -h            # each directory in /var, smallest to largest
sudo du -xh -d 1 / | sort -h | tail -15   # the biggest top-level directories on /
du -ah /srv/uploads | sort -h | tail -20  # the 20 biggest files and directories
du -sh --exclude='*.iso' ~/Downloads

sort -h understands sizes such as 1.5G and 300M; see sort.

Hunting down a full disk

  1. df -h to see which file system is full.
  2. sudo du -xh -d 1 /mountpoint | sort -h to find the biggest directory.
  3. Repeat one level deeper until you find the culprit: usually logs, caches, old backups, core dumps or container images.
  4. For big single files: sudo find /mountpoint -xdev -type f -size +1G -exec ls -lh {} +.

For interactive browsing, install ncdu: sudo ncdu -x / lets you walk through directories sorted by size and delete from inside the tool.

When du and df disagree

macOS and BSD du support -h, -s, -d and -x but not the GNU long options.