How to Clean Your Ubuntu Machine
In general, Linux-based operating systems, like Ubuntu, manage computer resources quite well. However, sometimes users install many programs and don’t uninstall them afterwards, which leads to reduced memory and fragmented disk. As a result, the operating system may slow down. To avoid this, start disk cleaning and enhance the computer’s performance.
Before presenting some ways of cleaning your Ubuntu, let’s see how you can check free space in your system.
Check free space¶
The first thing you need is to find out which files are consuming the large bulk of the storage space in your disk. Use the Disk Usage Analyzer tool. Run the tool, and you will see the used and free space. After that, you can clear your system.
Uninstall unnecessary applications¶
Probably you have many applications that you don’t use any more. Uninstall the application with the following command:
sudo apt remove [application name..]..¶
Or, if you want to do the same without a command line, use the Ubuntu Software manager, where you’ll only need to click the “Remove” button.
Clean unnecessary packages and dependencies¶
Updating your system via the default updating tool can lead to the accumulation of packages that will fill the cache. This can mainly occur when you uninstall software packages, but their dependencies are left without any reason at all.
To remove the dependencies left behind once installed packages that aren’t needed any longer, use this command:
sudo apt-get autoremove¶
Clean the thumbnail cache¶
There are thumbnails used by Ubuntu to make some operations on your computer to perform them faster. They are like cookies and cache in browsers.
The thumbnails increase over time, and the computer does not clear them automatically. Instead, Ubuntu has a command to clear them.
- Check the size of the thumbnails of your system before deleting them:
- Run the following command to delete this cache:
du -sh ~/.cache/thumbnails¶
sudo rm -rf ~/.cache/thumbnails/*¶
Clean the Apt cache¶
APT (Advanced Package Tool) cache is the place where all the downloaded, installed, and uninstalled files of your system are kept. Ubuntu keeps them in your /var/cache/apt/archives directory.
- Check the size of the APT cache on your system:
- Clear this cache entirely with this command:
sudo du -sh /var/cache/apt¶
sudo apt-get clean¶
Or, you can also clean up only absolutely not necessary packages that can’t be found in the repositories any more, or they have new versions located:
sudo apt-get autoclean¶
Remove orphaned package¶
Besides the dependencies files, packages can also become orphaned when you uninstall an application. To get rid of orphan files, you can make use of “gtkorphan”, a graphical interface for “deborphan”. Use this command:
sudo apt-get install gtkorphan¶
Remove unnecessary kernels¶
If old kernel versions remain on your disk (which can depend on how your system is set up), you can try the following command:
sudo dpkg --list 'linux-image*'¶
Remove locale files¶
Unless you need to switch to several locales all the time, you can uninstall the unused ones and free up some storage space in your system.
You can either install the localepurge package or use the following command:
sudo apt-get install localepurge¶
Once the installation is done, it will remove all locale files from your system that you have no need for.