How to Fix bash: ncdu: command not found in Minimal Linux

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 ncdu in base package repositories.
  • PATH Environment Omission: The binary is located in /usr/bin/ncdu or /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.

  1. Update your local package index:
    sudo apt update
  2. Install the ncdu package:
    sudo apt install -y ncdu
  3. Launch the utility on your root filesystem:
    sudo ncdu /
  4. To scan without crossing into mounted network or external filesystems, add the -x flag:
    sudo ncdu -x /
  5. 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.

  1. Install and enable the EPEL (Extra Packages for Enterprise Linux) repository:
    sudo dnf install -y epel-release
    (On legacy CentOS 7, execute sudo yum install -y epel-release).
  2. Install ncdu via DNF:
    sudo dnf install -y ncdu
  3. 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.

  1. Update package indexes:
    apk update
  2. Install ncdu:
    apk add ncdu
  3. 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.

  1. 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
  2. Extract the tar archive:
    tar -xvf ncdu-2.4-linux-x86_64.tar.gz
  3. Move the standalone binary into your system PATH:
    sudo mv ncdu /usr/local/bin/
  4. Verify execution:
    ncdu --version

Method 5: Add ncdu to Dockerfile Definitions

If you build maintenance and debugging containers, embed ncdu into your container specification.

  1. Open your project Dockerfile in a text editor.
  2. For Ubuntu/Debian containers, append:
    RUN apt-get update && apt-get install -y --no-install-recommends ncdu && rm -rf /var/lib/apt/lists/*
  3. For Alpine Linux containers, append:
    RUN apk add --no-cache ncdu
  4. Rebuild your Docker image to make ncdu permanently available for container storage diagnostics.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.