We’ve all, at some point, needed to check our disk usage. If it was on your desktop PC or laptop running OS X or Windows then it’s fairly simple to do. However when all you’ve got to hand is a command line you have to rely on some extensive commands to work out a range of files sizes in a directory. Granted working out the overall disk usage on CentOS can be fairly simple with the program “df” but we’ve got a much faster and more efficient way of analysing your files.
NCdU, short for NCurses Disk Usage is a very efficient way of getting an overview of your directories and the usage within them. You can do much more with this tool however I mainly use it to get an idea of the size of a directory and then being able to check what file in that directory is the cause of such high disk usage, all within a couple of clicks.
Steps for Installing NCDU on CentOS 6
First, to make sure you do not already have it installed, simply check by typing “ncdu” as follows:
root@urpad-vps [~]$ ncdu
-bash: ncdu: command not found
If you get “command not found” then you don’t have it installed so it’s ok to move forward. Start off by installing the EPEL 6 repository to yum, you can do this simply by typing this command:
rpm -ivh http://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
You should see something like this:
Retrieving http://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
Preparing... ########################################### [100%]
1:epel-release ########################################### [100%]
If you don’t see the message like the one above then something is wrong, most likely it could be something wrong with “rpm” itself. If that is the case then just paste your error in the comments.
Once the command is successful you can go ahead and run the install command for ncdu. Just type the following:
yum -y install ncdu
You should then see something like this:
Installed:
ncdu.x86_64 0:1.7-1.el6
Complete!
That is a fairly good indication that it is installed successfully. But just to make sure you can execute the program by typing:
root@urpad-vps [~]$ ncdu
Hopefully you will now see a nice looking screen showing you the sizes of directories and files in the current directory you’re in. Make sure to “cd” to the directory you want to look at before you execute “NCDU“. You can type “?” to get help on what commands are what.
If you have any issues with installing it or any questions about the program please let me know below by submitting your comments. If you have a preferred method of analyzing your disk usage then we’d love to know!
Luis Pichardo says:
This is a nice utility never heard of it before tough. I’m going to install it on my VPS’s
Stewart says:
Great! I use it all the time, extremely useful tool!
Greg says:
Thanks for this, its a useful tool I had never head of. It helped me fix a vps that was not working. Keep up the good work with these guides.
Stewart says:
Thanks Greg, glad it helped!