Introduction
Ncurse Disk Usage (or simply ncdu) is a disk analyzer that provides information about the distribution and use of disk space on a computer or server.
Ncdu works in text mode using the curses library, which allows you to display information in a human-readable format in the terminal. It scans the specified directory and provides detailed information about the size of directories and files.
In this guide, we will show how to install it on Debian (10,11 and 12) and Ubuntu (all versions).
Installation and Use Guide
1. Update System
First, update the system:
apt update
Then run the upgrade command:
apt upgrade
2. Install Ncdu
To install ncdu run this command:
apt install ncdu
3. Launch The Ncdu
Once the ncdu is installed, you can launch it by running this command:
ncdu
This command will scan your working directory and open the ncdu interface.
4. Navigation In Ncdu
Once scanning is completed, ncdu will show you the structure of files and directories together with their disk usage:
To navigate through the files, use the arrow key. It will allow you to move up and down. To see information about selected directory (path, disk usage) press i.
To hide this window, press i again.
5. Sort Files And Directories In Ncdu
By default, files and directories are sorted by size. However, the ncdu interface offers different options for sorting them.
For example, you can sort them by name. For that, press n
.
To bring back the default option and sort by size, press s
.
To check all the options, press Shift+?
.
6. Delete Files And Directories In Ncdu
To delete file or directory, select it with ncdu and press -d.
Ncdu will prompt you to confirm the removal. Select "Yes" or "No".
7. More Information About Ncdu
To see information about all the options, press Shift+?
. It will show you the ncdu "help" window:
8. Exit From Ncdu
To exit from ncdu, simply press q
.
Conclusion
Now you can easily analyze your server disk storage with the graphical interface of ncdu to identify what files/folders are taking the most space. The ncdu user-friendly interface allows you to free up space on your VPS quickly.