How to Use the ncdu Command to Analyze Disk Usage Interactively in Linux

When your Linux server or desktop runs out of disk space, finding the exact files or directories responsible can be a challenge. While the standard du (disk usage) command is powerful, it outputs a massive, unformatted wall of text that is difficult to read. The solution is ncdu (NCurses Disk Usage), an interactive, visual disk usage analyzer that runs directly in the terminal.

How to Install ncdu

Because ncdu is not installed by default on most Linux distributions, you must download it from your package manager.

  • On Ubuntu/Debian systems: sudo apt install ncdu
  • On RHEL/CentOS/Fedora systems: sudo dnf install ncdu
  • On Arch Linux: sudo pacman -S ncdu

How to Analyze Disk Usage

To start using the tool, open your terminal and simply type the command:

ncdu

By default, ncdu will scan the directory you are currently sitting in. If you want to scan your entire hard drive from the root level, run the command with sudo privileges and point it to the root directory (/):

sudo ncdu /

The program will display a progress bar as it calculates the size of every file and folder. Depending on the size of your disk, this may take a few minutes.

How to Navigate the Interactive Interface

Once the scan is complete, ncdu will present a visual list of your directories, ordered by size from largest to smallest. The interface uses a graphical bar chart drawn with text characters to represent the size.

  • Use the Up and Down Arrow keys to scroll through the list.
  • Press Enter to open a directory and dive deeper into its contents.
  • Press the Left Arrow key to go back up to the parent directory.
  • If you find a massive log file or an old backup you no longer need, press the d key to permanently delete it directly from the interface (use caution, as there is no recycle bin).
  • Press q to quit the program and return to the standard terminal prompt.

Get the best tech tips delivered straight to your inbox.

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