ncdu: showing folder sizes in the console and finding disk space hogs

The disk is full and nobody knows why? ncdu (NCurses Disk Usage) gives you a clear view in the console of which folders take up how much space – sorted by size and browsable with the arrow keys. Unlike with du, you do not have to work through long text output, and unlike graphical tools, ncdu also works over SSH on any server.

Installation

ncdu is available in the repositories of all common distributions:

# Ubuntu / Debian
sudo apt install ncdu

# Fedora / RHEL (EPEL)
sudo dnf install ncdu

# Arch Linux
sudo pacman -S ncdu

Basic usage

Without parameters ncdu scans the current directory. For the whole system the following is recommended:

sudo ncdu -x /

The -x option makes ncdu stay on the file system instead of descending into mounted drives, network shares or /proc. That makes the scan faster and the result more meaningful. sudo is needed so that directories such as /var/log or /root are counted as well.

The most important keys

KeyFunction
↑ ↓ / j kSelect an entry
→ / EnterOpen a folder
← / hGo up one level
s / n / CSort by size / name / number of files
gToggle percentage and bar display
iShow details for the entry
dDelete a file or folder (asks for confirmation)
rRescan the current directory
qQuit
?Help

Be careful with d: deleted files do not end up in a trash folder. If you only want to look, start ncdu in read-only mode with ncdu -r.

Useful options

# Exclude specific paths
sudo ncdu -x / --exclude /home/backup --exclude '*.iso'

# Read-only, deleting disabled
sudo ncdu -r -x /

# Write the result to a file and view it later
sudo ncdu -x / -o /tmp/scan.ncdu
ncdu -f /tmp/scan.ncdu

Exporting in particular is handy: the lengthy scan of a large drive runs once (for example at night via cron), and you look at the result later.

Scanning a remote server

ncdu does not necessarily have to be operated on the target system. The scan runs on the server, the display locally:

ssh root@server 'ncdu -x -o- /' | ncdu -f-

Typical space hogs

  • /var/log – above all the systemd journal; clean up with sudo journalctl --vacuum-size=200M
  • /var/cache/apt – downloaded packages; empty with sudo apt clean
  • /var/lib/docker – old images and containers; clean up with docker system prune
  • /var/lib/snapd – old snap revisions
  • Old kernels – see Ubuntu & Debian: safely removing old kernel versions

Alternatives

For a quick overview without an extra package, du -h --max-depth=1 / 2>/dev/null | sort -h is enough. If you are looking for an overview of all drives rather than folders, df -h or duf is the better choice. gdu is a very similar alternative to ncdu that is sometimes faster on SSDs.

Originally published in 2012, completely revised in November 2026.