$linuxjunkies
>

du(1)

Summarize disk usage of files and directories, showing how much space each one occupies.

UbuntuDebianFedoraArch

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

FlagWhat it does
-h, --human-readablePrint sizes in human-readable format (K, M, G, T) instead of blocks
-s, --summarizeDisplay total for each argument; do not show subdirectories
-c, --totalProduce a total sum at the end of the output
-a, --allShow usage for all files, not just directories
-d, --max-depth=NLimit output to N directory levels deep
-S, --separate-dirsDo not include size of subdirectories in directory size
-x, --one-file-systemSkip directories on different filesystems
--timeShow last modification time of each file or directory
-B, --block-size=SIZEScale sizes by SIZE before printing (e.g., 1M, 1K)
--exclude=PATTERNExclude files matching PATTERN from calculation

Examples

Show total size of /home directory in human-readable format

du -sh /home

Show 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 /var

List each user's home directory size sorted from smallest to largest

du -sh /home/* | sort -h

Find the 20 largest files and directories in /tmp

du -a /tmp | sort -rn | head -20

Show 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

Related commands