Monday, September 01, 2008

Keeping your Ubuntu clean

GNU/Linux is said to be one of the most stable operating systems in the market, which is why a lot of people prefer it as their server solution. But as a desktop, Linux and especially Ubuntu with GNOME, can get easily oversized without the proper care and before you know it, you end up with 1% free disk size of your root (or "/") partition; and taking up stress-relieve medicaments just doesn't seem right...

Here's a list of things I tend to do when such crisis strikes:
  1. Clear your Recent documents using the menu Places → Recent Documents → Clear Recent Documents
  2. If you use chat (IRC or Instant messaging), clear your log files.
    The following list contains client applications and their default folder log location:
    I strongly recommend closing your applications before removing any log files!!


  3. After constantly installing and removing software, some leftover information might be just clogging your disk space for no apparent reason. The apt-based package management has two commands when you remove packages: remove and purge. The difference is that purge actually deletes the configuration files that are deliberately left there when you used remove, in case you want to install it again.
    a) But which packages have their configuration files left over? Run Terminal (head to menu Applications → Accessories → Terminal) and execute the following command:
    dpkg -l | grep -i '^rc' | tr -s ' ' | cut -d ' ' -f 2
    Another way to find these out it to head to System → Administration → Synaptic Package Manager → Click "Status" (lower left corner) → Select "Not Installed (residual config)"
    Now in the package list, right-click on the package that you wish to completely remove (aka purge) and select "Mark for Complete Removal". Then you press "Apply" and let it flow.
    Tip: Press SHIFT+A to select them all.

    b) Leftover package dependencies that were installed with your applications might still be around. You can clear them all out by executing the following in terminal:
    sudo apt-get autoremove --purge

    c) Ubuntu packages are cached in the folder /var/cache/apt/archives/, which can also get clogged up by numerous packages that are either updated or not used anymore. You can solve that by executing in terminal:
    sudo apt-get autoclean
    sudo apt-get update
    If you really want to clear all the packages archived:
    sudo apt-get clean
    sudo apt-get update

    d) To remove obsolete packages go to System → Administration → Synaptic Package Manager → Click "Status" → Installed (local or obsolete) → Mark the packages you wished to be completely removed (or preferably removed).
    Warning: These section includes packages that have been manually installed by third-party packages (not from ubuntu repositories), if you need them, don't remove them!
  4. A lot of linux kernel versions in your GRUB boot menu? Time to get rid of them! Use step 3(d), and mark packages that begin with linux- for complete removal
    Warning: These section includes packages that have been manually installed by third-party packages (not from ubuntu repositories), if you need them, don't remove them!

  5. Clear the temporary files created with gedit - to do this, you have to search for them.
    Go to menu Places → Search → Click "Select more options".
    Now select "Show hidden and backup files" and click "Add".
    Also add the "Name matches regular expression". Next to this last one you will type ~$, which will find all filenames that end with "~" character and most of them are temporarily created by gedit (gnome's text editor). Press "Find".
    Now you can select the files you want to delete and right-click → Move to trash.

    Warning: Some files are temporary application files that are deleted when you end the application. It might be best not to mess around a lot with this one.

6. Clear your temporary flash-related cached files found in .macromedia folder by executing this command in terminal:
rm -rf $HOME/.macromedia/
(thanks Simon!)


Simon said...

+= rm -fr ~/.macromedia

Ozan said...

These are really cool tips. I knew lots of them already but it's very practicle to have them all collected on one page ^_^