Whenever you are running out of disk space on Ubuntu server/desktop , There are several ways to free up space on ubuntu and other linux based systems.
I have listed down some command line tricks here!
1. Check disk space
Your will get an output that shows the space
2. Clear APT Cache
Ubuntu keeps a cache of the installed packages which are downloaded or installed earlier even after uninstallation. Cache files in this location /var/cache/apt
To check the disk space consumed you can use the following command.
sudo du -csh /var/cache/apt
Output will be look like
Now you can clean this cache using the following command.It will clean up entire cache which frees up more space.
sudo apt-get clean
If you wish to clean up only the outdated packages, you can use the following command.
sudo apt-get autoclean
3. Remove unused packages and Kernels
You can remove the kernels & packages that are no longer needed and that are installed from Ubuntu archive while system updates using the following command.
Note: This command will not remove the kernels that are installed manually.
sudo apt-get autoremove --purge