When a Linux server runs out of disk space, identifying the exact files or directories consuming the storage can be a tedious process using traditional df and du commands. The ncdu (NCurses Disk Usage) utility provides a fast, interactive, terminal-based interface that allows you to visually navigate your filesystem and instantly identify storage hogs without running complex command chains.
How to Install ncdu on Ubuntu and Debian Linux
The ncdu utility is not installed by default on most Linux distributions, but it is readily available in standard repositories. Because it is incredibly lightweight, installation takes only a few seconds.
- Open your terminal or SSH into your remote Linux server.
- Update your package repository index by typing:
sudo apt updateand pressing Enter. - Install the utility by running:
sudo apt install ncdu - Confirm the installation if prompted.
For RHEL, CentOS, or Fedora systems, you can install the package using sudo dnf install ncdu instead.
How to Scan and Analyse Disk Usage with ncdu
Running the tool is straightforward, but for system-wide analysis, you should always run it with root privileges so it can access all user directories and system logs.
- To scan the entire root filesystem, type the following command:
sudo ncdu / - Press Enter. The utility will immediately begin scanning your disk. Depending on the size of your drive, this may take a few minutes.
- Once the scan completes, you will be presented with an interactive, sorted list of directories, with the largest folders appearing at the top.
How to Navigate the ncdu Interface
The true power of ncdu lies in its keyboard-driven navigation, which allows you to drill down into massive directories instantly.
- Use the Up and Down arrow keys to highlight different directories.
- Press the Right arrow key or Enter to open a highlighted directory and view its contents.
- Press the Left arrow key to return to the parent directory.
- Press d while highlighting a file or folder to delete it permanently. (Use extreme caution, as there is no recycle bin).
- Press q to quit the interface and return to your standard bash prompt.
By using this interactive approach, you can quickly locate overgrown application logs, abandoned database dumps, or massive cache folders that are unnecessarily consuming your storage capacity.