How To Set Up & Use Ncdu In Linux

How To Set Up & Use Ncdu In Linux

In this article, we will show how to set up Ncdu and how to use ncdc in Linux for a better overview of Disk Usage

The default disc use command for UNIX-based systems summarizes the sizes of directories on trees, taking into account both their entire contents and the sizes of individual files. Finding your system’s space hogs, though, is useful. To put it another way, it will list the directories and files that take up a lot of room on the hard drive.

What is NCDC?

Over time, ncdu was receiving a tonne of online recommendations. A disc-use analyzer with a ncurses interface is called NCDU. To examine the disc utilization, however, we’ll describe how to install ncdu on a *UNIX-based system in this piece.

How to Install NCDC?

To install NCDU, you need to see what is Distro you are using, and use one of the below codes too:

1. Debian-based install
The apt command to install ncdu:

sudo apt install ncdu

2. CentOS/RHEL/Fedora installs:
To install on CentOS/RHEL/Fedora you need to enable EPEL repository using this command:

sudo yum install epel-release

Now, you can run the ncdu installation command on CentOS:

sudo yum install ncdu

Or, If you use Fedora, you should use

sudo dnf install ncdu

3. To Alpinr Linux install:
You can try to install it using following the APK command:

apk add ncdu ncdu-doc

4. OpenSUSE/SUSE Linux:
we use zypper, For this system:

sudo zypper in ncdu

5. Arch Linux:
On arch Linux, you can use pacman:

pacman -S ncdu

6. FreeBSD unix:
Type the following command on your terminal:

sudo pkg install ncdu

7. OpenBSD:
– There’s little difference on this one, so you need to copy to install it:

doas pkg_add ncdu

How you can use NCDU

Its syntax is really easy to use, just follow the instructions below:

ncdu
ncdu <flags> <directories>

If neither the flags nor the directory is given, the command will look in your current working directory. When you run the command, a list of the disc utilization of each directory starting from the current one will appear. You only need to hit “Q” to leave that list.

Using NCDU, you may obtain information from any directory, just use:

ncdu /root
ncdu /home
ncdu /var/log

NCDU flags

We’ll go over some of the flags that can be used with the NCDU command in that section. The flag “-x” is the first one.

This option enabled root filesystem scanning of the entire system. You can utilize it by running:

ncdu -x /

With the flag -e, we can additionally enable the extended information mode. To do this, run:

ncdu -e

You can add this by using the “-color” flag if you want your ncdu responsive to have some colors:

ncdu --color dark -x /

Files that match the supplied pattern can also be excluded:

ncdu --exclude '.ht*'
ncdu -x --exclude '/var/log/ --exclude '/directory2' --exlucde ... /

Many more are listed in their handbook, along with shortcuts:

man ncdu

That’s it. You have mastered the NCDU’s fundamental syntax and installed it successfully on Linux. Now that you have it, you may utilize it to improve the usage description on your server.

Was this article helpful to you? If you continue to have problems with the outlined above, please contact the eTechSupport Team.

Follow us on FacebookTwitter, and LinkedIn for additional information.


Get your free trial now