Cheatsheet: du
Last updated 2026-09-18
Basic usage
Show disk usage for directories below the current directory in block-size units.
Show sizes in human-readable units such as K, M, and G.
Summarize the total size of one directory.
Summarize each item directly inside a directory.
Show a grand total after listing individual arguments.
Depth and scope
Limit output to the current directory and one level of children.
GNU equivalent for limiting output depth.
Show apparent file size instead of allocated disk blocks, useful for sparse files.
Stay on one filesystem and do not cross mounted filesystems.
Count hard-linked files every time they are encountered instead of once.
Finding large items
Sort files and directories by size, smallest first.
Sort by size, largest first.
Sort human-readable sizes, largest first.
Show the ten largest items in the current directory.
Show only entries at or above a threshold size with GNU du.
Show entries at or below a threshold size with GNU du.
Excluding paths
Exclude a directory name pattern such as node_modules.
Exclude multiple glob patterns using repeated --exclude options.
Read exclude patterns from a file with GNU du.
--max-depth reference (GNU coreutils)
Semantics: --max-depth=N prints a total for every directory N or fewer levels below each argument, and hides deeper subdirectory lines. Files are only shown at all when -a/--all is also given; without -a, du only ever lists directory totals, and --max-depth simply limits how many directory levels are shown.
-d N is the short-option alias for --max-depth=N added by GNU coreutils; they are interchangeable.
--max-depth=0 is equivalent to -s/--summarize: only the grand total for each argument is printed, with no subdirectory detail.
Depth is measured relative to each argument you pass, not your current working directory — pointing --max-depth=1 at a parent path surfaces that path's own children, not yours.
--max-depth is a GNU extension (no POSIX standard, and BSD/macOS du lacks it, though BSD's -d N option is comparable). Check your platform's du before relying on GNU-only flags in portable scripts.