How to clean Ubuntu safely

Back to the home page

First of all: never use cleaning applications like Bleachbit! They are very risky and may damage your system beyond repair. There are a few safe cleaning actions, which I'll describe below.

Ubuntu doesn't get polluted much over time. It even doesn't need defragmentation. The only cleansing actions you might want to do in Ubuntu, are the following:

Clear the updates cache

1. Use Ubuntu Software Center to install Synaptic Package Manager.

Click on the grey Ubuntu logo (Dash home). Query: synaptic.
Click on Synaptic Package Manager

Settings - Preferences - Files

Put the dot at: Delete downloaded packages after installation

Press the button: Delete cached package files

Remove unused remains of uninstalled software

2. Still in Synaptic Package Manager:

In the lower left corner of the Synaptic window, click on the button Status.
Then, in the upper left corner, click the following line:
Not installed (residual config)

Mark all shown packages for complete removal and click Apply.

Clear the thumbnail cache

3. For each shown picture, Ubuntu automatically creates a thumbnail, for viewing in the file manager. It stores those thumbnails in a hidden directory in your user account (names of hidden directories and hidden files start with a dot, like .cache or .bash_history. The dot makes them hidden).

Over time, the number of thumbnails can increase dramatically. Moreover, the thumbnail cache will eventually contain many superfluous thumbnails of pictures that don't exist anymore.

My advice is therefore, to clear the thumbnail cache every six months or so. The quickest way is to use the terminal:

Launch a terminal window.
(You can launch a terminal window like this: *Click*)

Type (use copy/paste to avoid errors):

rm -f ~/.cache/thumbnails/normal/*

Press Enter.

Repeat the above in each user account.

You can permanently limit the size of the thumbnail cache as follows:

Note: for this, you have to install the package dconf-tools first.

Launch a terminal window.
(You can launch a terminal window like this: *Click*)


Press Enter

In dconf-editor, click on the small triangle to expand a category. Like this, click your way to:
org - gnome - desktop - thumbnail_cache
.... and set the maximum-age to 90 (press Enter) and the maximum-size to 64 (press Enter again).

Close dconf-editor.

Repeat this in each user account.

The registry

4. There's no need to clean the registry of Linux, as it can't get polluted in the first place. For the following reasons:

- Only the operating system itself has a central registry. The configurations of the applications aren't in there, because they don't have access to it. So they can't mess it up. They place their own default settings in their own folders in the system.

- applications place upon installation a hidden settings file in the personal folder of each user. That's the only settings file that a user has access to. More or less like MS-DOS did, when each application only created its own .ini file with its settings.

- each user has his own hidden copy of the central registry in his personal folder. That copy is the only thing that he can mess up, not the registry of another user account.

(continued in the column on the right)

This website is being sponsored by Google Ads.

Are you using an ad blocker? Then you're also blocking my earnings from advertisements....

If you wish to support my website, you can configure your ad blocker to make an exception for this website.

Thanks in advance....

Remove old kernels

5. After a kernel update, the old kernel still shows in the Grub boot menu, under the header: "Advanced options for Ubuntu". Because you might want to start your machine with the old kernel, if the new kernel doesn't function well.

So far, so good. But having more than one redundant kernel, is superfluous and a waste of disk space: each kernel uses up more than 200 MB (headers included). This is how you can remove old kernels and thereby clean up the Grub boot loader menu as well:

An Ubuntu version sticks to the main kernel version it had on release date. Kernel updates are only minor versions of that main version.

For example: Ubuntu 14.04 was first released with 3.13.0-24. It will always remain 3.13, but the minor version number receives regular updates.

Now let's get started (based on the example of 14.04):

a. First determine which minor kernel version is active now:

Launch a terminal window.
(You can launch a terminal window like this: *Click*)

Type (use copy/paste to avoid errors):

uname -r

Press Enter.

Now you see the active minor kernel version, for example:

The active one has to remain intact; all older versions can safely be removed. As follows:

b. Launch the Ubuntu Software Center and install Synaptic Package Manager, because Synaptic does a better removal job.

c. Then click on the grey Ubuntu logo (Dash home). Query: synaptic.
Click on Synaptic Package Manager.

linux-image 3.13

(use the Search button and not the buggy Quick search)

Mark all installed kernels that you want to remove, for "complete removal".

Then remove all of them by pressing the Apply button in the panel.

Note: take care not to remove the latest kernel!

Tip: also leave the latest redundant old kernel in your system, just to be on the safe side.

d. Now reboot your computer.

e. Then copy/paste this line into the terminal:
sudo apt-get autoremove

Press Enter. Your password will remain entirely invisible, not even dots will show when you type it, this is normal. Press Enter.

Finished! That's all you ever need to do. Doing more is risky and not advisable.

Note: don't use cleaning applications like Bleachbit and Computer Janitor for this job. They are dangerous and at best nearly useless.

Make Firefox cleanse itself automatically upon quitting

6. Improve your privacy: you can configure Firefox to cleanse itself automatically, upon quitting. All cookies and history are being deleted then. Furthermore, you can limit the tracking that some websites do to follow you.

The price you pay is a small decrease in user friendliness, but it's not much. The privacy gain is huge, and outweighs this price by far.

You can do it like this:
Panel of Firefox - Edit - Preferences - tab Privacy

a. Item Tracking: set it to:
Tell sites that I do not want to be tracked

b. Item History: change the setting to:
Firefox will: Use custom settings for history

c. Item Cookies: change the setting to:
Keep until: I close Firefox

d. Now tick the following setting:
Clear history when Firefox closes

e. Finally, click the button "Settings..." and tick everything, except for Saved Passwords and Site Preferences. Click OK.

Click Close and you're done.

Tip: sometimes it may come in handy to force a cleansing during your web browsing. Simply by closing Firefox and launching it anew.

Want more tips?

7. Do you want more tips and tweaks for Ubuntu? There's a lot more of them on this website! For example 10 fatal mistakes that you'll want to avoid in Ubuntu.

To the content of this website applies a Creative Commons license.