How to Use the ncdu Command to Find Large Directories in Linux

When a Linux server’s hard drive fills up, it can cause databases to crash and web servers to fail. Finding exactly which files or folders are consuming the most space using standard command-line tools like df and du is notoriously slow and difficult to read.

The solution is a third-party utility called ncdu (NCurses Disk Usage). ncdu provides a fast, interactive, and visually intuitive interface directly within the terminal, allowing you to navigate through your file system and instantly identify massive directories.

In this guide, you will learn how to install and use the ncdu command to reclaim disk space on your Linux server.

Step 1: Install ncdu

Unlike df or du, ncdu is not usually installed by default, but it is available in almost every major Linux distribution’s software repository.

To install it on Ubuntu or Debian, run:

sudo apt update && sudo apt install ncdu -y

To install it on CentOS, RHEL, or AlmaLinux, run:

sudo dnf install epel-release -y
sudo dnf install ncdu -y

Step 2: Run a System Scan

You can run ncdu against a specific directory, or against the entire file system.

To scan the entire server (starting from the root directory), type:

sudo ncdu /

Note: Running it with sudo is crucial if you are scanning the root directory, otherwise it will not have permission to read the sizes of system files and logs.

A progress bar will appear as ncdu rapidly calculates the size of every single file on the server. On modern SSDs, this usually takes only a few seconds.

Step 3: Navigate the Interface

Once the scan is complete, you will be presented with a highly readable, interactive list. The directories are automatically sorted by size, with the largest folders at the very top.

The interface relies entirely on your keyboard:

  • Up and Down Arrows: Move the cursor up and down the list.
  • Right Arrow (or Enter): Drill down into the highlighted directory to see what is taking up space inside it.
  • Left Arrow: Go back up one directory level.
  • q: Quit the application and return to the standard terminal prompt.

Next to each folder, you will see the exact size in human-readable formats (e.g., GB, MB) and a visual hash bar graph (#####) representing how much relative space it consumes.

Step 4: Delete Files Safely

If you drill down into a folder (like /var/log/) and find a massive, outdated archive file that you want to delete, you do not need to exit ncdu to do it.

  1. Use your arrow keys to highlight the specific file or folder you want to delete.
  2. Press the d key on your keyboard.
  3. A red warning box will pop up, asking you to confirm the deletion.
  4. Select Yes and press Enter. The file is permanently deleted, and ncdu instantly recalculates the directory sizes.

Warning: Be extremely careful when using the delete function. There is no recycle bin in Linux; once you press Yes, the file is gone forever. Never delete system libraries or files you do not recognize.

By utilising ncdu, you transform the tedious chore of disk management into a fast, visual, and highly efficient process.

Get the best tech tips delivered straight to your inbox.

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