du(1)
Summarize disk usage of files and directories, showing how much space each one occupies.
Synopsis
du [OPTION]... [FILE]...Description
The du command estimates file and directory space usage by walking the file tree and summing block counts. It reports disk usage in blocks (typically 1024 or 4096 bytes) or human-readable units. When given a directory, it shows usage for that directory and all subdirectories.
By default, du includes all files and writes one line per directory. Common use cases include finding large directories, tracking storage changes over time, and identifying disk space hogs on a filesystem.
Common options
| Flag | What it does |
|---|---|
-h, --human-readable | Print sizes in human-readable format (K, M, G, T) instead of blocks |
-s, --summarize | Display total for each argument; do not show subdirectories |
-c, --total | Produce a total sum at the end of the output |
-a, --all | Show usage for all files, not just directories |
-d, --max-depth=N | Limit output to N directory levels deep |
-S, --separate-dirs | Do not include size of subdirectories in directory size |
-x, --one-file-system | Skip directories on different filesystems |
--time | Show last modification time of each file or directory |
-B, --block-size=SIZE | Scale sizes by SIZE before printing (e.g., 1M, 1K) |
--exclude=PATTERN | Exclude files matching PATTERN from calculation |
Examples
Show total size of /home directory in human-readable format
du -sh /homeShow size of each item in current directory in human-readable format
du -sh *Show disk usage up to 2 levels deep in /var with human-readable sizes
du -h -d 2 /varList each user's home directory size sorted from smallest to largest
du -sh /home/* | sort -hFind the 20 largest files and directories in /tmp
du -a /tmp | sort -rn | head -20Show size of each log directory with a total at the end
du -sch /var/log/*Show top-level directory sizes without crossing filesystem boundaries
du -x -h -d 1 /Show directory usage excluding MP4 video files
du -h --exclude='*.mp4' /home/user