Cleaning up a Ubuntu GNU/Linux system

If you want to clean your ubuntu machine you need to follow these simple steps to remove all unnecessary junk files.

Remove Residual Config packages

In Synaptic Package Manger, there is a built-in feature that gets rid of old Residual Config packages. Residual Config packages are usually dependency packages that are left behind after you uninstall a package from your machine. To use this feature, go to System > Administration > Synaptic Package Manager. On the bottom left hand corner of the window,click the Status button. In the list above the Sections, Status, Search, and Custom buttons, you should see the following text

Installed(auto removable)
Installed(local or obsolete)
Not installed
Not Installed (Residual config)

Click on the “Residual config” text. (If the “Residual config dialogue does not appear, that means you do not have any Residual Config packages on your machine.

If you want to remove you need to select those packages and click on apply from menu bar Remove packages are in progress

Remove partial packages

This is yet another built-in feature, but this time it is not used in Synaptic Package Manager. It is used in theTerminal. To access the Terminal, go to Applications > Accessories > Terminal. Now, in the Terminal, key in the following command

sudo apt-get autoclean

Remove unnecessary locale data

For this we need to install localepurge.Automagically remove unnecessary locale data.This is just a simple script to recover diskspace wasted for unneeded locale files and localized man pages. It will automagically be invoked upon completion of any apt installation run.

Install localepurge in Ubuntu

sudo apt-get install localepurge

After installing anything with apt-get install, localepurge will remove all translation files and translated man pages in languages you cannot read.

If you want to configure localepurge you need to edit /etc/locale.nopurge

This can save you several megabytes of disk space, depending on the packages you have installed.


I am trying to install dicus using apt-get

sudo apt-get install discus

after end of this installation you can see something like below

localepurge: Disk space freed in /usr/share/locale: 41860K

Remove “orphaned” packages

If you want to remove orphaned packages you need to install deborphan package.

Install deborphan in Ubuntu

sudo apt-get install deborphan

Using deborphan

Open Your terminal and enter the following command

sudo deborphan ¦ xargs sudo apt-get -y remove --purge

Remove “orphaned” packages Using GtkOrphan

GtkOrphan (a Perl/Gtk2 application for debian systems) is a graphical tool which analyzes the status of your installations, looking for orphaned libraries. It implements a GUI front-end for deborphan, adding the package-removal capability.

Install GtkOrphan in Ubuntu

First you need to download latest version of GtkOrphan from here using the following command


Now you have gtkorphan_0.4.2-2_all.deb package you need to install this using the following command

dpkg -i gtkorphan_0.4.2-2_all.deb

At the time of installation you get the following error

dpkg -i gtkorphan_0.4.2-2_all.deb
Selecting previously deselected package gtkorphan.
(Reading database … 175891 files and directories currently installed.)
Unpacking gtkorphan (from gtkorphan_0.4.2-2_all.deb) …
dpkg: dependency problems prevent configuration of gtkorphan:
gtkorphan depends on deborphan (>= 1.7.17); however:
Package deborphan is not installed.
gtkorphan depends on libgtk2-gladexml-perl; however:
Package libgtk2-gladexml-perl is not installed.
dpkg: error processing gtkorphan (–install):
dependency problems – leaving unconfigured
Errors were encountered while processing:

You need to use the following command to fix

sudo apt-get -f install

This will complete the installation.Once you finished the installation go to System—>Administration—>Remove Orphaned Packages

Now it will prompt for password enter your password

Once it opens you should see the following screen

Non-orphaned packages list screen shot

GtkOrphan Version Details

Now you need to select the orphaned packaged and click on ok

You need to confirm the removal of packages

Removing Requested packages in progress

Remove Orphan packages using Wajig

simplified Debian package management front end.Wajig is a single commandline wrapper around apt, apt-cache, dpkg,/etc/init.d scripts and more, intended to be easy to use and providing extensive documentation for all of its functions.

With a suitable sudo configuration, most (if not all) package installation as well as creation tasks can be done from a user shell. Wajig is also suitable for general system administration.A Gnome GUI command ‘gjig’ is also included in the package.

Install Wajig in Ubuntu

sudo apt-get install wajig

This will complete the installation if you want to open this you can use GUI tool using the following command


Once it opens you should see the following screen

If you want to view orphan packages select Orphans

If you want to use wajig from the command line you can see the following help

Try the help command for a list of common commands provided by wajig:

$ wajig help

Examples commands include:

$ wajig update (= dselect update)
$ wajig install less (= apt-get install less)
$ wajig new (list new packages since last update)
$ wajig newupgrades (list packages upgraded since last update)
$ wajig toupgrade (list all packages to be upgraded)
$ wajig updatealts editor (update the default “editor”)
$ wajig restart apache (restart the apache daemon)
$ wajig listfiles less (list the files supplied by the “less” pkg)
$ wajig whichpkg stdio.h (what package supplies this header file)
$ wajig whatis rats (one line description of the package “rats”)
$ wajig orphans (list libraries not required by other pkgs)

For a complete list of available commands increase the level of verbosity of the help command

$ wajig -v help
debfoster – Keep track of what you did install

debfoster maintains a list of installed packages that were explicitly requested rather than installed as a dependency. Arguments are entirely optional, debfoster can be invoked per se after each run of dpkg and/or apt-get.

Alternatively you can use debfoster to install and remove packages by specifying the packages on the command line. Packages suffixed with a – are removed while packages without a suffix are installed.

If a new package is encountered or if debfoster notices that a package that used to be a dependency is now an orphan, it will ask you what to do with it. If you decide to keep it, debfoster will just take note and continue. If you decide that this package is not interesting enough it will be removed as soon as debfoster is done asking questions. If your choices cause other packages to become orphaned more questions will ensue.

Install debfoster in Ubuntu

sudo apt-get install debfoster

Using debfoster

to create the initial keepers file use the following command

sudo debfoster -q

you can always edit the file /var/lib/debfosterkeepers which defines the packages you want to remain on your system.

to edit the keepers file type

sudo vi /var/lib/debfoster/keepers

To force debfoster to remove all packages that aren’t listed in this list or dependencies of packages that are listed in this list.It will also add all packages in this list that aren’t installed. So it makes your system comply with this list. Do this

sudo debfoster -f

To keep track of what you installed additionally do once in a while :

sudo debfoster

xdiskusage – Check where the space on your hard drive goes

Displays a graphic of your disk usage with du.xdiskusage is a user-friendly program to show you what is using up all your disk space. It is based on the design of the “xdu” program written by Phillip C. Dykstra. Changes have been made so it runs “du” for you, and can display the free space left on the disk, and produce a PostScript version of the display.xdiskusage is nice if you want to easily see where the space on your hard drive goes.

Install xdiskusage in Ubuntu

sudo apt-get install xdiskusage

If you want to open this application you need to use the following command

sudo xdiskusage

Once it opens you should see similar to the following screen


Posted on February 17, 2008, in How-to, linux, OS and tagged , , , , . Bookmark the permalink. 2 Comments.

  1. Thanks! This was a very informative post, considering I had planned to spend the afternoon cleaning out the ‘cruft’ from my laptop today.

  1. Pingback: php code and scripts » Blog Archive » Cleaning up a Ubuntu GNU/Linux system

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: