If you find your server seems to be running out of disk space, the first thing you should do is figure out how full your disk really is. After that, you'll need a way to quickly zero in on which files and folders are using up the most disk space unnecessarily.

If you're interested in check the disk usage of your server, you probably need to know a thing or two about dev ops. For that, I recommend reading The DevOps Handbook.

Scroll down to continue reading.

First, you should make sure that you actually are running out of space. The utility df is useful for seeing exactly how much space is available on each of your partitions. Run it with the "-h" option to get the results printed in "human-readable" units.

df -h

The Output of df -h

On Windows, you can use WinDirStat, and on Ubuntu Desktop, you can use Baobab to quickly find folders that are much larger than they should be.

Baobab on Ubuntu Linux

WinDirStat and Baobab are two programs with graphical user interfaces that let you quickly find large files and folders. On Ubuntu server, you don't have the luxury of a graphical user interface. That's wher ncdu comes in. Ncdu is basically Baobab for the command line.

Installing and running ncdu is a breeze:

sudo apt install ncdu
cd /

And navigation within ncdu is intuitive: just use the arrow keys and "enter". Make sure you launch ncdu while you're in "/" because you can only scan and navigate to directories under the present working directory. Once you've figured out what files are taking up too much space on your disk, press "q" to quit ncdu.

NCDU User Interface

Have you had out of disk space issues on your server? What was the cause? Let me know in the comments!

Photo by Andrew Hart