Skip to content

ncdu - NCurses Disk Usage Analyzer Cheatsheet

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

PlatformCommand
Ubuntu/Debiansudo apt install ncdu
Fedora/RHELsudo dnf install ncdu
Arch Linuxsudo pacman -S ncdu
openSUSEsudo zypper install ncdu
Alpinesudo apk add ncdu
macOS (Homebrew)brew install ncdu
FreeBSDsudo pkg install ncdu

Basic Usage

CommandDescription
ncduScan the current directory
ncdu /Scan the whole filesystem
ncdu /var/logScan a specific path
ncdu -x /Stay on one filesystem (don’t cross mount points)
sudo ncdu /Scan with root to include protected files
ncdu --helpShow all options
KeyAction
/ or j / kMove the selection
/ Enter or lEnter the selected directory
or hGo up to the parent directory
nSort by name
sSort by size (default)
CSort by item count
aToggle apparent size vs disk usage
gToggle percentage / graph display
?Help screen
qQuit

Managing Files

KeyAction
dDelete the selected file or directory
iShow information about the selected item
tToggle directories-before-files in sort
eShow/hide hidden files
rRecalculate (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.

CommandDescription
ncdu -o scan.json /Scan and export results to a file
ncdu -o- / > scan.jsonExport to stdout (redirect to a file)
ncdu -f scan.jsonOpen a previously saved scan (offline)
ssh host 'ncdu -o- /' > scan.jsonScan a remote box, browse it locally

Options Worth Knowing

OptionDescription
-xDo not cross filesystem boundaries
--exclude PATTERNSkip paths matching a glob
--exclude-kernfsSkip pseudo-filesystems (/proc, /sys)
-rRead-only mode (disable delete)
-qQuiet/slower refresh over slow links
--color darkEnable 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

ncdu vs Other Disk-Usage Tools

ToolStyleBest for
ncduInteractive TUINavigate + delete, remote servers
dustOne-shot tree+barsQuick visual overview (Rust)
dufMounts/usage tables”How full are my disks?“
duPlain textScripting and pipelines

Resources