NCDU – command

NCDU stands for NCurse Disk Usage which is Linux program that displays Disk usage statistics in a Ncurse menu, which makes things easier to see what is using up space on your disk.

To install on Red Hat/CentOS & Debian/Ubuntu:

~# yum install ncdu
~# apt-get install ncdu

Once installed open your shell and run:

~# ncdu [path to directory]

The biggest directory will appear at the top of the list which makes it easier to diagnose.

You may need to compile the software and have the right curse development libraries:

~# yum install ncurses-devel
~# apt-get install libncurses5-dev

Then, extract the software downloaded and compile it using default options:

~# ./configure -prefix=/usr && make && make install

Once compiled:

You can now scan /usr/lib directories and generate a report to a specified file:

~# ncdu /usr/lib -o disk-usage.txt

If you have a look at this file you will see that there are lots of information that it may seem complicated to understand at a first glance. But, this file will be used by NCDU to display that same NCurse menu with all data collected previously.

~# ncdu -f disk-usage.txt

You could also create a crontab to generate a report, compress it into a folder and then have ncdu open it to analysis it. Below is a bash script that could be added to a cron job later:

#This is a script that will generate compressed NCDU reports based on the date
nice -n15 ncdu -qxo- /|gzip > /tmp/disk_report-${DATE}.gz
#END of script

The script above generates a report of all Linux directories and compresses them using the GZIP command, which then generates a file called disk_report based on the actual date.

You can decompress and view the report:

~# zcat /tmp/disk_report-17-04-2013.gz | ncdu -f –


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s