Featured image of post ncdu — The TUI Tool for Quickly Understanding Linux Disk Usage

ncdu — The TUI Tool for Quickly Understanding Linux Disk Usage

Installation, usage, and practical tips for ncdu, an ncurses-based TUI disk usage analyzer.

Overview

When an EC2 instance runs low on disk space, df and du alone make it hard to pinpoint which directories are consuming the most storage. ncdu is an ncurses-based TUI tool that visually analyzes disk usage.

Installation

# Ubuntu/Debian
sudo apt-get install ncdu

# CentOS/RHEL
yum install -y ncdu

# macOS
brew install ncdu

Basic Usage

# Analyze current directory
ncdu

# Analyze a specific path
ncdu /var/log

# Analyze entire disk
ncdu /

After scanning, ncdu displays a tree of directories and files with graphical bar indicators. It’s immediately obvious where storage is being consumed.

Key Controls

KeyAction
Arrow keysNavigate directories
EnterEnter subdirectory
iItem info
dDelete selected item (with confirmation)
? / Shift+?Help
qQuit

How ncdu Compares to df and du

ToolStrengthsWeaknesses
dfInstantly shows per-partition total usageDoesn’t tell you which directory is the problem
duCalculates per-directory sizesOutput is long and sorting is tedious
ncduInteractive TUI, instant sorting, in-place deletionRequires separate installation

Insights

For server disk management, ncdu does what htop does for process management — the same operations are possible with the basic commands (df, du), but interactive TUI navigation changes efficiency dramatically. Especially in disk-constrained environments like EC2 when disk unexpectedly fills up, ncdu handles everything from diagnosing the cause to cleaning up, all without leaving the terminal.

Built with Hugo
Theme Stack designed by Jimmy