# Disk usage with du and ncdu

> How to find what fills a Linux disk with du and the interactive ncdu, with options that stay on one file system.

du (disk usage) is the standard Linux command that reports how much space files and directories use; ncdu is an interactive, ncurses-based alternative that lets you browse the results and delete items. Together with df, which shows free space per file system, they are the usual way to find what fills a disk.

## Useful du options

'du -sh /var' prints one human-readable total. 'du -h --max-depth=1 /' lists the size of each top-level directory. '-x' stays on one file system, so mounted disks and /proc are skipped.

Piping to sort finds the biggest items: 'du -xh --max-depth=1 / | sort -h'.

## ncdu

'ncdu -x /' scans the root file system and opens a browsable list sorted by size. Arrow keys move, Enter opens a folder, 'd' deletes the selected item after confirmation, 'q' quits. ncdu is usually installed from the distribution's package (for example 'apt install ncdu').

## When du and df disagree

If df reports a full disk but du finds less, a deleted file may still be held open by a running process. The space returns when that process closes the file or restarts.

## How to find what fills the disk

1. See which file system is full: df -h
2. List the biggest top-level folders: sudo du -xh --max-depth=1 / | sort -h
3. Go one level deeper into the largest folder and repeat.
4. Or browse interactively: sudo ncdu -x /

## Cautions

- Do not delete files you do not recognise in /usr, /lib, /boot or /var/lib.
- 'd' in ncdu deletes immediately after you confirm; there is no recycle bin.

## Sources

- [du(1)](https://man7.org/linux/man-pages/man1/du.1.html)
- [ncdu(1) (Debian)](https://manpages.debian.org/bookworm/ncdu/ncdu.1.en.html)
- [df(1)](https://man7.org/linux/man-pages/man1/df.1.html)

Last updated: 2026-10-08
URL: https://raincleaner.eu/wiki/linux/disk-usage-du-ncdu
