Check disk usage on Linux with df, du and ncdu
Find out how full your disks are and which directories use the most space with df, du and ncdu. Every command tested on Debian, Ubuntu, Fedora and Arch.
When a disk fills up, two questions matter: which file system is full, and what is taking up the space. df answers the first, du answers the second, and ncdu lets you explore the answer interactively. df and du are part of GNU coreutils, so they are already installed on every mainstream distribution.
See how full each file system is with df
df reports used and available space per mounted file system. The -h option prints sizes in human-readable units such as G and M:
df -h /Without a path, df -h lists every mounted file system. Adding -T shows the file system type, which helps you tell real disks apart from virtual file systems like tmpfs:
df -hTFind what uses the space with du
du adds up the space used by files and directories. To get one total for a directory, use -s (summarize) together with -h:
du -sh /usr/shareTo find the biggest subdirectories, limit the depth with --max-depth=1 and sort the result. sort -h understands human-readable sizes, so 2G correctly sorts above 900M:
du -h --max-depth=1 /usr | sort -h | tail -n 5On a real system, run this as root (with sudo) on directories such as /var, otherwise du skips folders you are not allowed to read and prints “Permission denied” warnings.
Explore interactively with ncdu
ncdu scans a directory once and then lets you browse the results with the arrow keys, sorted by size. It is not installed by default. On Debian and Ubuntu:
sudo apt-get update
sudo apt-get install -y ncdu
ncdu --versionOn Fedora:
sudo dnf install -y ncdu
ncdu --versionThen start it on the directory you want to inspect. Use the arrow keys to move, Enter to open a directory and q to quit:
sudo ncdu /Quick reference
| Task | Command |
|---|---|
| Free space on all file systems | df -h |
| Free space with file system type | df -hT |
| Total size of one directory | du -sh DIR |
| Five biggest subdirectories | du -h --max-depth=1 DIR | sort -h | tail -n 5 |
| Interactive browser | ncdu DIR |
Sources
This article was drafted with AI assistance, fact-checked against the sources listed above and reviewed by a human editor before publication. Spotted an error? See our corrections policy.