As we all know Linux and distributions can be installed and used smoothly on as low as 20GB of disk space.
But with time disk space is something that is never abundant.
Unlike Windows, Linux and its distros don't come with tools like defragmenter hence after sometime Ubuntu gets slower due to unnecessary files and applications taking up space on the disk.
So, to keep the Ubuntu system steady and fast you need to get rid of unneeded trash at regular intervals.
In this context, we shall look into methods to free up the disk space in Ubuntu and be never short on disk space.
This tasks can be completed via GUI as well as from the command-line.
Different methods to free up disk space on Ubuntu ?
1. Remove APT Cache
Every time we install any application or package using Terminal, APT creates and keeps a cache of the previously downloaded and installed app or package on the disk. The cache of these apps and packages stays on disk even after they are uninstalled from the system.
APT also known as Advance Package Tool is used by Ubuntu to install, uninstall, and manage applications on the system. Generally, a cache of DEB packages is stored in the location /var/cache/apt/archives.
To know the exact size of the cache, run the following command in Terminal.
$ sudo du -sh /var/cache/apt
Now you have two options to remove the APT cache, either to remove only outdated packages or remove all of them.
Remove only outdated packages:
$ sudo apt-get autoclean
Remove all packages
$ sudo apt-get clean
2. How to use Stacer to free up disk space on Ubuntu ?
Stacer is an open-source system optimizer that helps you keep track of your system’s performance. It is a modern tool with a modern user interface which makes it attractive and easy to use.
It is a feature-rich tool and you can also clean up disk space using its dedicated feature.
3. How to Remove Old Kernels
You can remove old kernels from your system which are no longer required. But you have to do this step with caution because it may damage the system.
Old kernels can leave huge junk of files on the disk and slow down the Ubuntu system. Use the following command to remove the old Kernels from the system.
Before removing the older kernel, you must check the installed Linux kernel versions on your system.
To do this run the following command in Terminal.
$ sudo dpkg --list ‘linux-image*’
Now you can remove the older version using the following command.
$ sudo apt-get remove linux-image-version
Or simply you can run the following command to remove old kernels.
$ sudo apt-get autoremove --purge
4. How to Uninstall Unnecessary Applications ?
Everyone has some applications on their system they hardly use and these applications only there to eat some space on disk which can be used for better purposes.
So, head over to Ubuntu Software Centre and then click on Installed. Here you will see the list of apps and games installed on your system.
You can uninstall the apps or games you don't use or need and free up some space on your disk.
5. How to Keep System Up to Date ?
From the smartphone OS to the desktop OS I use, I like to keep them up to date.
As soon as updates get released, I update my system. It helps me keep my system smooth and fresh.
Not many recommend this but it is worth it. Some updates also bring fixes that stop apps and packages from occupying too much of disk space.
So, it is always a good idea to keep your system up to date.