4 More Ways to Clean Up Your Ubuntu Machine

It doesn’t matter if you are using Windows, Linux or Mac, as long as you don’t maintain it, it will grow out of hand and become very messy. Previously, we have discussed 8 useful ways and Bleachbit to help you maintain a clean lean Ubuntu machine. This time, we are going to show you 4 more ways to keep your Ubuntu clean.

When you delete a file, it will be moved to the trash and remain there infinitely until you empty your trash. If you have completely no use for the file, why not delete it permanently and free up some space?

In your Nautilus (file manager), go to Edit -> Preferences. Under the Behavior tab, check the box “Include a Delete command that bypass Trash“. Click Ok.

ubuntu-nautilus-delete

Now, right click at a file and you can see the “Delete” button below the Move to Trash option.

ubuntu-rightclick-delete

Selecting this Delete option will delete your file completely.

Update: Thanks to Carl, you can also permanently delete your files using the “Shift + Delete” keyboard shortcut.

If you have been moving files to the trash instead of deleting them permanently, there is a high chance that your trash bin is full of useless stuff that take up valuable space. You can easily empty your trash to free up the space.

Autotrash is a simple Python script which will purge files from your trash based on their age or the amount of free space left on the device. You can set it to delete files that have been in the trash for more than XX days, or if you are running out of space, you can get it to delete XX megabytes of files (in the trash) to free up the space.

There is currently no GUI for Autotrash, so everything has to be done via the command line.

To install, open the terminal and type

sudo add-apt-repository ppa:bneijt/ppa
sudo apt-get update
sudo apt-get install autotrash

To get it to your trash that is more than 30 days old, use the command:

autotrash -d 30

To get it to purge at least 30 MB of files

autotrash --delete=30

To set it to run only if 100MB of space is available

autotrash --max-free=100

A good way to maintain your trash is to run the Autotrash script every time you log in to your system. Go to System -> Preferences -> Startup Applications. Click Add.

Fill up the box as shown in the screenshot below:

ubuntu-autotrash-startup

With this command, Autotrash will run every time you login to your computer and purge the trash if the files are at least 30 days old.

If you need help with Autotrash, simply type

autotrash --help

to display the list of command available for Autotrash.

As you remove applications, delete files or move files around different folders, it will often end up with plenty of empty folders in your Home directory. While these empty folders don’t take up a lot of spaces, they can really mess up your directory structure and become very unsightly.

The find command can display all the empty folders in your Home directory.

find ~/ -type d -empty

To find and remove the empty folders in your Home directory, run the following command:

Important: Never run the find and remove command in root directory. Some of the empty folders are there for a purpose. Removing them might cause system instability

find ~/ -type d -empty -exec rmdir {} \;

The Grub 2 menu is the first thing that you see when you turn on your PC. Whenever the system installs a new kernel, it will add several entries to the Grub 2 menu. After several months of using Ubuntu, you will find that the list of entries in your Grub menu grew longer than your screen can display.

What happened is that when the system updates the new kernel, it doesn’t remove the old kernel. The new kernel is then added to the Grub menu and make the list longer. The easiest thing to clean this up is to remove the old kernel. You have no use for them anyway. Furthermore, kernel files can take up substantial space in your system, so it is also not a good idea to keep them around.

Open your Synaptic Package Manager and search for “linux-headers“. Identify the kernel with the highest version number, in this case, linux-headers-2.6.32-24. This is the kernel that you are going to keep. Proceed on to remove all other kernels that have a version number less than the one you have identified earlier (for example, linux-headers-2.6.32-22). Remember to select the option “Mark for Complete Removal”.

ubuntu-delete-linux-headers

This should remove the old kernels, free up your disk space and keep your Grub menu clean.

What other ways do you use to clean up your system?

Image credit: allen.goldblatt