How to Use ncdu (NCurses Disk Usage)  To Easily Obtain Disk Usage Information in Linux

One of the major issues that we see come in from most of our clients’ support tickets is about running out of disk space on their hosting, be it a VPS, dedicated servers or shared hosting. There are separate issues that actually cause this, sometimes log files which don’t have log rotate set up correctly, unused image thumbnails not being cleaned up etc. We are not going to get into the details at this time of the issues that cause most websites to run out or space. We will be covering that in a future post.

In this post, however, we want to talk about a very useful tool that allows us in our day to day troubleshooting of disk space problems to see a very nice representation of the folders that are taking up all the space on our client servers and allows us to drill down to the most problematic ones.

The name of the tools is ncdu (NCurses Disk Usage). ncdu is a curses-based version of the well popular disk usage ‘du’ command which provides a fast and visually appealing way to see what directories are using your disk space making it easy to identify all the large folders on your Linux computer.

The output of ncdu is easier to read because it uses ncurses (which stands for new curses) which is a programming library providing an application programming interface (API) that allows programmers to write text-based user interfaces in a terminal-independent manner, in other words, ncurses is essentially a toolkit for developing “GUI-like” application software that runs under in the command line.

How to use ncdu to find large folders in Linux

First of all we need to install ncdu if you don’t have it installed. We are going to show you how to install it on the two major Linux distributions. The first command would be for Ubuntu and then CentOS. To install ncdu on Ubuntu, use, apt-get to install like in the command below:

sudo apt-get install ncdu

For CentOS use:

yum install epel-release
yum install ncdu

Once this has been successfully installed like in the screenshot below, you can navigate to the folder you want to check the site of.

To navigate to the folder you want to start checking on just use the cd command and visit the approprate folder. In the example people we want to look at how the folders are using the space on the /etc folder. So we just change directory into that folder and run ncdu.

To view all available options under ncdu just type man ncdu for a whole host of options.

We hope your learned something new from this post about how to check disk usage statistics in Linux. Feel free to reach out to one of our experts to talk about the best ways we can help you speed up your website and troubleshoot any website issues you might be facing. If you enjoyed reading this article or it was a helpful resource, then please share it or leave a comment below and let us know what you think.