Cheatsheet: du

Last updated 2026-06-21

Basic usage

Show disk usage for directories below the current directory in block-size units.

du

Show sizes in human-readable units such as K, M, and G.

du -h

Summarize the total size of one directory.

du -sh public

Summarize each item directly inside a directory.

du -sh public/*

Show a grand total after listing individual arguments.

du -ch public/*

Depth and scope

Limit output to the current directory and one level of children.

du -h -d 1 .

GNU equivalent for limiting output depth.

du -h --max-depth=1 .

Show apparent file size instead of allocated disk blocks, useful for sparse files.

du -sh --apparent-size disk-image.raw

Stay on one filesystem and do not cross mounted filesystems.

du -xh /

Count hard-linked files every time they are encountered instead of once.

du -hl .

Finding large items

Sort files and directories by size, smallest first.

du -s public/* | sort -n

Sort by size, largest first.

du -s public/* | sort -nr

Sort human-readable sizes, largest first.

du -sh public/* | sort -hr

Show the ten largest items in the current directory.

du -sh ./* | sort -hr | head -n 10

Show only entries at or above a threshold size with GNU du.

du -h --threshold=100M .

Show entries at or below a threshold size with GNU du.

du -h --threshold=-1M .

Excluding paths

Exclude a directory name pattern such as node_modules.

du -h --exclude='node_modules' .

Exclude multiple glob patterns using repeated --exclude options.

du -h --exclude='node_modules' --exclude='.git' .

Read exclude patterns from a file with GNU du.

du -h --exclude-from=.duignore .

See also: