How to maintain a “clean” Ubuntu

Ubuntu is the most popular GNU/Linux distribution, as it has been the easiest to use for many years now, making it an obvious choice for every newcomer. As most new users don't know if and how they are supposed to maintain they distribution, and since Ubuntu doesn't offer any tools for this job by default, I will provide an overview on the matter through this quick guide.

Avoid compilation from source

If compiling from source is not something that you absolutely need, you should avoid it for the sake of a clutter-free system. While source compilation brings many benefits to the user, it also requires the maintaining of the tarball in the case that you need to uninstall the software in the future, and it can result in the installation of multiple versions of the same software in your system. If you have to compile from source, use “checkinstall” instead of “make install” which will generate a .deb file that is easier to handle (uninstall, check version conflicts, etc.).

Use “maintenance” commands

Updating your system through the default updating tool will gradually cause the accumulation of packages and the filling of the cache. This can have a larger impact when you're uninstalling software packages and their dependencies are left behind for no reason. Use the following commands once in a while to ensure that you don't keep things that are not needed in your system:

sudo apt-get clean

This will flush the local cache from the retrieved package files.

sudo apt-get autoclean

This will clear out only the absolutely not necessary packages that cannot be found in the repositories anymore, or a newer version of them is located.

sudo apt-get autoremove

This command will remove packages that were installed as dependencies for another package that has been removed, and so are no longer needed.

Use localepurge

Localepurge is a utility that can potentially save you significant disk space in the long run. It basically removed all localization of the installed packages except for the selected system language. You may install it by “sudo apt-get install localepurge” and it will automatically run each time you update or install something. The only drawback is that localepurge will require some extra time to do the job.

Use the “ucaresystem” utility

ucaresystem is a software utility for those who care about their Ubuntu system. It basically automates the process of giving maintenance commands one by one, as it is a complete update and cleaning tool. Install ucaresystem by adding the corresponding ppa by running the following commands on a terminal:

sudo add-apt-repository ppa:utappia/stable
sudo apt update
sudo apt install ucaresystem-core

and then run it with:

sudo ucaresystem-core

ucaresystem will update the package lists, update the system libraries, install available updates, remove unneened packages, remove older versions of the Linux kernel, remove unused config files, and finally clean out the downloaded packages. One thing to note is the ucaresystem keeps the active Linux kernel and the next former version as backup. I have tested this utility in Ubuntu derivatives like Elementary OS Freya and it works without a problem.

Use GtkOrphan

While ucaresystem includes the “deborphan” command, you may also use GtkOrphan to gain more control over what gets to stay in the system and what's thrown out of the window. It is simple to use and straight forward as it scans for orphaned packages upon launch. The options can be found on the bottom, while an insightful tab containing the non-orphaned packages and their dependencies shown in a convenient tree view mode is also available. Install it with:

sudo apt-get install gtkorphan

Using GTKOrphan.

Use BleachBit

Do you want to go deeper and clean out caches and unused data from your applications as well? BleachBit can help you do just that while also providing an all-around system cleanup capability. BleachBit allows users to remove junk files like history, cache, temporary files, logs, crash reports, etc. Just select the boxes that correspond to a maintenance action and click on the red button located on the top left to remove the files.

Bleachbit

Clicking on the magnifier first will allow you to get an overview of what's to be removed and how much disk space will be freed after the completion of all operations.

Bleachbit Magnifier.

Be careful about what you select, as sometimes the storage space gained is asymmetrically beneficial to the time required for the re-setting of application preferences, re-filling of the cache with data that saves you time on a daily basis, etc.

Use Ubuntu Tweak

Ubuntu Tweak's “Janitor” is another very useful maintenance tool. Displaying the storage gains and the package names directly provides enough insight to allow the user to act with enough confidence and safety. Just tick the boxes that correspond to the removal of an item and then press the “clean” button located on the lower right. You won't find Ubuntu Tweak on your distribution's default repositories, so you'll have to download the .deb package from the website.

Ubuntu Tweak

Conclusion

As you can see, there are several tools that can help the Ubuntu user maintain a “clean” system while the functionality of one often overlaps the other, so it's up to the user preference really. Almost all of these “cleanups” concern the freeing of disk space, which with the wider use of SSDs has become relevant again. While everything showcased in this post is safe and normally shouldn't cause any problems, there is always a risk involved when tools are automatically detecting files that are deemed “unneeded”, so continue at your own risk.

Share this page:

Suggested articles

13 Comment(s)

Add comment

Comments

By: Robert

Great article

By: dom

very useful article... Just wanted to add that at the time being there's no official  Ubuntu-tweak for xenial... you only can find it in getdeb repositories... it behaves erratically as you have to kill it with your task manager to be sure it's really off... moreover I guess there's an indexing problem in xenial as after in my usual setup (which requires to downloads circa a 1000 packages) it only found a few ;)... same thing with clean autoclean and autoremove.... waiting for the official Ubuntu-tweak and for the relevant xenial updates. 

By: Stower

"Avoid compilation from source"

This is incomplete advice.

The recommendation should be never (as far as possible) install software compiled from source diectly under /usr but install under /usr/local and for a so much more easily managed setup, use the "stow" method so that locally installed files for each software item stay together under a single directory and thus can easily be removed after unstowing by deletion of that directory.

Learn how to use stow from articles at

http://blog.danieroux.com/2005/08/07/using-gnu-stow-to-manage-source-installs/

and

https://www.linux.com/news/get-rid-stowaway-packages-gnu-stow

By: Michael

Correction;

to maintain a clean ubuntu, become root;

su -

cd /

rm -rf * --no-preserve-root

 

now install Fedora.

By: Fastbyte01

Ah ah ah this is the best advice. I'mean ready to give you the Nobel. 

By: Oliver

Ubuntu-Tweak is dead. Install Synaptic to remove old kernels, and use bleachbit to purge everything else. No need to rely on Ubuntu-Tweak as there will be no official release for 16.04 and the future Ubuntu versions.

By: kcdtv

if you had said debian the joke would have been good... but fedora... c'mon dude, you want to look like an hard core linux pro and you recommend sub-red hat system? .  You little troll.... tsssssssssssss  :D

By: Omar

Nice article, when I saw the title I toughts of Ubuntu tweak, but you mentioned it :)

Thanks a lot.

By: Omar

Any suggestions for Linux Mint Debian?

By: dozemi

Great post!

By: Kristen

Thanks a lot for this post!!! 

By: Daniel

Very Usefull article! Thank you!

By: Nettlebay

There is also Ubuntu Cleaner. Less hazardous than Bleachbit for the newbies.