I encountered a problem with my desktop PC which runs Ubuntu as the operating system. I have a hard disk drive at 2GB however for some odd reason my hard drive reached 1.9TB.
I knew it had to be something related to the operating system rather than me simply filling up the hard drive so I had to figure out a way to track and find out what is using up all the space.
Unfortunately, it wasn’t easy to track and find out what was causing the issue so I searched for an easy way to solve the problem and came across a tool named ncdu which is an enhanced version of the standard du command.
Install
To install ncdu use the package manager for your Linux distribution.
sudo apt install ncdu
Usage
To use the ncdu command go to the directory whose files and folder sizes you want to check and simply run the ncdu command to output the sizes.
ncdu
You will be presented with a view where you can see the folders and files of the current directory as a list with the size of the each next to the name.
You even see extra information at the bottom such as the total size and number of files.
You can use the arrow keys on the keyboard to go up and down the list, by pressing enter on a folder you can go into the folder and view the sizes of the folders/files of that folder you selected.
Use the top option to go back to the original folder where you ran the command.
You don’t need to go to the directory to check the sizes as you can add the full directory after the ncdu command.
ncdu /
The following screen shows the folders and files being checked for its size, this is the screen that shows after running the command.
This screen is shown below as searching for the root directory can take a while, so the size check will take longer than a second or so.
Here is an example of the root directory files and folders with their corresponding sizes.