When storage volumes run low on disk space, tracking down which directories or files consume the most gigabytes is a top priority for Linux system administrators. While standard commands like du -sh * provide raw text listings, ncdu (NCurses Disk Usage) offers a fast, interactive terminal-based interface that lets users visually navigate directory trees, inspect file sizes, and delete large unnecessary files with a single keystroke. However, on newly bootstrapped minimal servers, cloud droplets, or Docker containers, running the command frequently fails with the error: bash: ncdu: command not found.
Why Is the ncdu Command Missing on Linux?
The ncdu utility is an optional third-party disk auditing tool rather than a part of the standard GNU coreutils suite. Key reasons for its absence include:
- Omission from Minimal OS Images: Minimal cloud images (such as Ubuntu minimal, Debian-slim, or Amazon Linux) exclude interactive terminal utilities to keep baseline image footprints tiny.
- EPEL Repository Prerequisite on Enterprise Linux: RHEL, CentOS, Rocky Linux, and AlmaLinux do not bundle
ncduin base package repositories. - PATH Environment Omission: The binary is located in
/usr/bin/ncduor/usr/local/bin/ncdu, which may be excluded in restricted shell environments. - Container Image Minimization: Docker images intentionally stripped of development and administrative packages.
Method 1: Install ncdu on Ubuntu, Debian, and Linux Mint
On Debian-derived distributions, ncdu is available directly in the primary universe repositories.
- Update your local package index:
sudo apt update - Install the
ncdupackage:sudo apt install -y ncdu - Launch the utility on your root filesystem:
sudo ncdu / - To scan without crossing into mounted network or external filesystems, add the
-xflag:sudo ncdu -x / - Use the Up and Down arrow keys to navigate, press Enter to open a directory, and press d to delete selected files interactively. Press q to quit.
Method 2: Install ncdu on RHEL, CentOS, Rocky Linux, and AlmaLinux
On Red Hat enterprise distributions, enable the EPEL repository before installing.
- Install and enable the EPEL (Extra Packages for Enterprise Linux) repository:
(On legacy CentOS 7, executesudo dnf install -y epel-releasesudo yum install -y epel-release). - Install
ncduvia DNF:sudo dnf install -y ncdu - Verify the command works:
ncdu -v
Method 3: Install ncdu on Alpine Linux and Docker Containers
Alpine Linux includes ncdu in its main repository branch.
- Update package indexes:
apk update - Install
ncdu:apk add ncdu - Test disk usage scanning:
ncdu /var/log
Method 4: Install Modern High-Performance ncdu 2.x (Zig-Based)
Modern versions of ncdu (version 2.x) are rewritten in Zig for drastically faster scanning speeds on large NVMe arrays.
- Visit the official ncdu release page or download the pre-compiled static binary:
wget https://dev.yorhel.nl/download/ncdu-2.4-linux-x86_64.tar.gz - Extract the tar archive:
tar -xvf ncdu-2.4-linux-x86_64.tar.gz - Move the standalone binary into your system PATH:
sudo mv ncdu /usr/local/bin/ - Verify execution:
ncdu --version
Method 5: Add ncdu to Dockerfile Definitions
If you build maintenance and debugging containers, embed ncdu into your container specification.
- Open your project
Dockerfilein a text editor. - For Ubuntu/Debian containers, append:
RUN apt-get update && apt-get install -y --no-install-recommends ncdu && rm -rf /var/lib/apt/lists/* - For Alpine Linux containers, append:
RUN apk add --no-cache ncdu - Rebuild your Docker image to make
ncdupermanently available for container storage diagnostics.