When you manage a Linux server, storage space is a premium commodity. If your 500GB hard drive suddenly fills up overnight, finding the massive rogue files causing the problem using the standard ls or du commands is a tedious, text-heavy nightmare. Instead, you can install and deploy the ncdu (NCurses Disk Usage) tool, which transforms the chaotic terminal into a beautiful, interactive, graphical interface that visually maps your entire hard drive.
Installing ncdu
The ncdu tool is not typically installed by default on basic Linux distributions, but it is readily available in all major repositories.
- On Ubuntu/Debian: Type
sudo apt install ncduand press Enter. - On CentOS/RHEL: Type
sudo yum install ncduand press Enter.
How to Scan Your Hard Drive
Once installed, you can launch the scanner from any directory. If you want to scan the entire server to find the absolute largest files on the hard drive, you must run it from the root directory.
- Open your Linux terminal.
- Type the following command to scan the root (
/) filesystem:
sudo ncdu /
- Press Enter.
The terminal will display a scanning progress bar as it mathematically indexes every single file on the server. Depending on the size of your drive, this can take a few minutes.
Navigating the Visual Map
When the scan finishes, the terminal will instantly transform into an interactive graphical dashboard. At the very top of the list will be the absolute largest folder on your entire server, accompanied by a visual hash-mark graph (#####) representing its massive size relative to everything else.
You can navigate this dashboard using your keyboard:
- Use the Up and Down arrow keys to scroll through the list.
- Press the Right arrow key (or Enter) to dive deep into a massive folder and see exactly which specific files inside are causing the problem.
- Press the Left arrow key to back out of a folder.
- If you find a massive, useless log file that is destroying your storage, you can press the d key to instantly delete it without ever leaving the dashboard.
Press q to quit the application when your drive is clean. The ncdu command is the absolute fastest way to surgically audit a dying Linux server.