Back to the command reference

du

DisksFundamentals In simulator In real Linux

Estimate file and directory space usage

Name: du = disk usage

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

du reports the disk space used by files and directories, recursing into subdirectories. It counts allocated blocks, so even a tiny file takes at least one block (usually 4K).

To find what is filling a disk, du -sh * or du -h --max-depth=1 combined with sort -h works well.

Syntax

du [OPTION]... [FILE]...

Common options

-s / --summarizeShow only a total for each argument
-h / --human-readableHuman-readable sizes
-a / --allList files as well as directories
-d / --max-depth NShow totals only down to depth N
-c / --totalAdd a grand total
--exclude PATTERNLeave out files matching PATTERN
-x / --one-file-systemSkip other file systems mounted below
--apparent-sizeUse the file sizes rather than disk blocks used

Examples

  • $ du -sh projects

    Total size of projects

    Explain
  • $ du -h .

    Size of every subdirectory here

    Explain

Related