Cleaning up Hard Drive Space in Linux

If you run into a situation where a Linux machine is running out of space, here’s a way to check what is taking up so much space and clean the server up.

Install ncdu:

sudo apt-get install ncdu

Afterwards, start ncdu and you’ll be presented with an interface that’ll walk you through the directories taking the most space:

Troubleshooting – My Drive is 100% Full

If you’re having trouble installing the above, you likely have a full drive that cannot do anything else. Here are a few steps that may help:

First, see if there are any individual files you can delete to clear some space (such as in the user directory). If this isn’t an option, go into /var/tmp and delete the files in there () this is not always a safe choice).

After that, run the following:

sudo apt-get clean
sudo apt install byobu
sudo purge-old-kernels
sudo apt autoremove
sudo update-grub

With this you should be able to install the above and check into what is taking up so much space.