Report issue Add example

ncdu

Interactive disk usage analyzer, regarded as an enhanced version of du

Description

ncdu (NCurses Disk Usage) is a disk usage analyzer for Unix-like systems, based on ncurses. It is an enhanced version of the traditional du command. Unlike the static text output of du, ncdu provides an interactive TUI interface, allowing you to browse the directory tree with arrow keys, sort results, view file information, and delete files directly.

It is ideal for quickly locating large files and analyzing disk space usage. Version 1.09 and later support exporting scan results as JSON.

Official Resources

Installation

ncdu is typically not pre-installed by default on most Linux distributions, but it is available in almost all major official repositories.

Debian/Ubuntu

sudo apt install ncdu

CentOS / Rocky / AlmaLinux

sudo yum install epel-release
sudo yum install ncdu

Fedora

sudo dnf install ncdu

Arch Linux

sudo pacman -S ncdu

macOS (Homebrew)

brew install ncdu

FreeBSD

pkg install ncdu

Syntax

ncdu [options] [directory]

Options

-h, --help             Display help information.
-v, --version          Display version information.
-x                     Stay on one file system (don't cross mount points).
-q                     Quiet mode: reduce screen refresh rate (useful for SSH).
-o FILE                Export scan results to FILE (JSON format, requires 1.09+).
-f FILE                Load scan results from a JSON FILE (requires 1.09+).
--exclude PATTERN      Exclude files or directories matching the pattern.
--exclude-from FILE    Read exclude patterns from a file.
--follow-symlinks      Follow symbolic links.
--confirm-deletion     Ask for confirmation before deleting a file.

Interactive Commands

↑, ↓, →, ← represent arrow keys.

Key Function
↑ / k Move cursor up
↓ / j Move cursor down
→ / Enter / l Open the selected directory
← / h Go back to the parent directory
n Sort by name (press again to toggle asc/desc)
s Sort by size (press again to toggle asc/desc)
d Delete selected item
g Toggle display of percentages and/or graph
t Toggle directory-first sorting
c Toggle display of child item counts
b Open a shell in the current directory
i View detailed information for the selected item
r Refresh/rescan the current directory
q Exit ncdu

Examples

Scan the current directory

ncdu

Scan a specific directory (e.g., /var/log)

ncdu /var/log

Export scan results to JSON (1.09+)

ncdu -o result.json /

Load results from a JSON file

ncdu -f result.json