ncdu: analyze disk space in command line on Linux

In this “‘little” tutorial, I will explain how to view and analyze the space in the command line on Linux with ncdu.

If you are adapted from WinDirStat or TreeSize on Windows, the ncdu utility on Linux allows you to have the “same” thing in a terminal.

The first thing to do is to install it, it is available for most distributions through their repositories.

To change, I used an Ubuntu machine.

Enter the command below under Ubuntu / Debian to install ncdu:

sudo apt install ncdu -y

Now we will see how to use it, it’s very simple.

Go to root (for example):

cd /

Once you are at the location you want to analyze, enter the command below to start the analysis:

sudo ncdu

Wait during the analysis which will take more or less time, depending on the number of elements and the speed of the disk(s).

Once the analysis is complete, ncdu displays at level n0 the volumetry of each folder.

To display the help, use the ? of the keyboard to open it:

To exit help, press the q key

Then it is possible to navigate through the folders to find the folder or file that is taking up space. Navigation is done using the arrow keys.

It is also possible to act by deleting (d) for example a folder or a file:

You now know how to analyze Linux server space with ncdu.

If the same tools could be available on Windows, that would be the TOP.

Leave a Comment