How to install and use ncdu on Linux

What Is Ncdu?

The name “NCurses Disk Usage” (or “Ncdu”) refers to a curses-based alternative to the well-known “du” command. It offers a quick method of determining which directories are taking up disk space.

The creator of the Ncdu software is not happy with all of the tools and methods available in Linux for analyzing disk utilization. Therefore, he used the C programming language and a ncurses interface to create Ncdu.

Ncdu is a straightforward and quick disk utilization analyzer used to determine which directories or files on local or distant computers are using up more space.

Without further ado, let’s get started learning how to install Ncdu in Linux and how to use it to check disk utilization in Unix-like operating systems like Linux.

Install Ncdu in Linux

You must determine the distro you are using in order to use one of the codes below to install Ncdu:

Debian-based install

sudo apt install ncdu

Install CentOS, RHEL, or Fedora

To enable the EPEL repository, run the following command on CentOS, RHEL, or Fedora before installing:

sudo yum install epel-release

After that, you may use CentOS to run the ncdu installation command:

sudo yum install ncdu

Alternatively, if you use Fedora run:

sudo dnf install ncdu

Installing in Alpine Linux:

The apk command can be used to try to install it:

apk add ncdu ncdu-doc

installing in SUSE/OpenSUSE Linux:

Zypper is used for this system:

sudo zypper in ncdu

Install ncdu in Arch Linux:

Pacman should be used on Arch Linux:

pacman -S ncdu

FreeBSD unix

In your terminal, enter the following command:

sudo pkg install ncdu

How to 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 disk 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 for 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 response 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:

That sums it up nicely. You have completed the Ncdu installation on Linux and are familiar with its fundamental syntax. It is now available for use on your system, and you may put it to use to improve the usage description on your server.

Leave a Reply

Your email address will not be published.