If you’re like me, and have a cheap VPS sitting in a datacenter somewhere, you’ve probably run out of storage quite a few times.
This post will show you a few ways to free up that storage:
Chances are, you have a bunch of apps that you don’t use. I recommend looking through
dpkg --list | less
to see all the packages, and remove the ones you don’t use. Afterwards, the following will also free up some space:
sudo apt clean
sudo apt autoclean
sudo apt autoremove
and all unused packages, and the apt cache, will be removed.
The easiest way to search for big files is by using a program called ncdu. To install, simply run:
sudo apt install ncdu
sudo ncdu /
and after a few minutes of searching, it will show you the biggest folders. Keep pressing enter on the highest one until you isolate the largest file, and see if you can delete it. If not, look for all the other large files, and chances are you won’t actually need quite a few of them.
If you have log rotation enabled, chances are that you have a bunch of .tar.gz files in /var/log. These are pretty much safe to remove, as the current logs will not be affected by:
although, as always, use caution with wildcards, especially with commands such as rm that can potentially break your system. I once deleted the entire /usr folder as a result of not watching what I was running, and I needed to re-install to fix the issue.
If you’ve exhausted all other options, you can always compress the files you need, but rarely use. There are tools such as tar and zip that will do this for you, simply install them and look at the man pages. If even this is not enough, then it’s probably time for an upgrade.