Rain Wiki · Linux

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.

Linux · Rain Wiki

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.

Note: RainServer offers monitoring and safe cleanup for Linux servers; it shows what will change and asks first.

Sources

Last updated: 2026-10-08

Related articles