ncdu - NCurses Disk Usage Analyzer Cheatsheet
ncdu (NCurses Disk Usage) is an interactive disk-usage analyzer that runs entirely in the terminal. It scans a directory tree once, then lets you browse it sorted by size, drill into subdirectories, and delete files or folders on the spot. Because it needs only a terminal, it is the go-to tool for finding what is eating space on a headless or remote server over SSH.
Installation
| Platform | Command |
|---|
| Ubuntu/Debian | sudo apt install ncdu |
| Fedora/RHEL | sudo dnf install ncdu |
| Arch Linux | sudo pacman -S ncdu |
| openSUSE | sudo zypper install ncdu |
| Alpine | sudo apk add ncdu |
| macOS (Homebrew) | brew install ncdu |
| FreeBSD | sudo pkg install ncdu |
Basic Usage
| Command | Description |
|---|
ncdu | Scan the current directory |
ncdu / | Scan the whole filesystem |
ncdu /var/log | Scan a specific path |
ncdu -x / | Stay on one filesystem (don’t cross mount points) |
sudo ncdu / | Scan with root to include protected files |
ncdu --help | Show all options |
Navigation Keys
| Key | Action |
|---|
↑ / ↓ or j / k | Move the selection |
→ / Enter or l | Enter the selected directory |
← or h | Go up to the parent directory |
n | Sort by name |
s | Sort by size (default) |
C | Sort by item count |
a | Toggle apparent size vs disk usage |
g | Toggle percentage / graph display |
? | Help screen |
q | Quit |
Managing Files
| Key | Action |
|---|
d | Delete the selected file or directory |
i | Show information about the selected item |
t | Toggle directories-before-files in sort |
e | Show/hide hidden files |
r | Recalculate (rescan) the current directory |
Export & Import (Remote Workflows)
ncdu can save a scan to a file and view it later or elsewhere — great for auditing a server without keeping an SSH session open.
| Command | Description |
|---|
ncdu -o scan.json / | Scan and export results to a file |
ncdu -o- / > scan.json | Export to stdout (redirect to a file) |
ncdu -f scan.json | Open a previously saved scan (offline) |
ssh host 'ncdu -o- /' > scan.json | Scan a remote box, browse it locally |
Options Worth Knowing
| Option | Description |
|---|
-x | Do not cross filesystem boundaries |
--exclude PATTERN | Skip paths matching a glob |
--exclude-kernfs | Skip pseudo-filesystems (/proc, /sys) |
-r | Read-only mode (disable delete) |
-q | Quiet/slower refresh over slow links |
--color dark | Enable a color scheme |
Common Workflows
# Find the biggest space hogs on a server, safely (read-only)
sudo ncdu -x -r /
# Audit a remote host without an interactive session
ssh prod-box 'ncdu -o- -x /' > prod-scan.json
ncdu -f prod-scan.json
# Clean a build cache directory interactively
ncdu ~/.cache # navigate, press d to delete
| Tool | Style | Best for |
|---|
| ncdu | Interactive TUI | Navigate + delete, remote servers |
| dust | One-shot tree+bars | Quick visual overview (Rust) |
| duf | Mounts/usage tables | ”How full are my disks?“ |
| du | Plain text | Scripting and pipelines |
Resources