Cleaning up a Ubuntu GNU/Linux system
Posted by admin on February 1st, 2007
Email This Post
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
Installed(auto removable)
Installed(local or obsolete)
Installed(upgradable)
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.
Example:-
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
wget http://ftp.debian.org/debian/pool/main/g/gtkorphan/gtkorphan_0.4.2-2_all.deb
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:
gtkorphan
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
gjig
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
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

If you want to be notified the next time we write something please subscribe to our RSS feed.Thanks for Visiting!


February 1st, 2007 at 2:24 pm
Excellent excellent, just the right one for space conscious ppl like me. Great tutorial.
February 7th, 2007 at 11:25 am
hi,what do u mean by orphan package?thx..
February 7th, 2007 at 11:52 am
orphan package means broken packages and if you uninstall some packages some of dependencies might leftout if you want to remove all these packages use this tutorial.
February 15th, 2007 at 5:46 pm
If you use “aptitude” instead of “synaptic,” it *automatically* removes orphaned packages when you remove a package. The drawback is that it has a text gui, but it is very easy to use.
February 17th, 2007 at 5:49 am
Edgy also includes “autoremove” as an extension of apt-get, so apt-get autoremove will remove any leftover packages that were dependencies if a package is uninstalled. So while aptitude removes dependencies as you remove an app, apt-get autoremove will get rid of anything that was left behind an uninstall performed by apt-get or Synaptic.
February 18th, 2007 at 11:15 am
So what is the different between apt-get autoclean and apt-get autoremove?
February 22nd, 2007 at 10:48 pm
For those worried about space, when you use apt or a front end to it (Synaptic, Add/Remove, Aptitude, etc) it keeps all the “install” files (.deb) it downloads in a cache, even after they’ve been installed. You can see them in /var/cache/apt/archives. Easiest way to manage this is in Synaptic, Preferences -> Files, you’ll see a button to delete the current cache, and options to choose what to do with these files in the future.
May 9th, 2007 at 4:00 pm
Glad I came across this site. I was just about to install Ubuntu Mint 2.2 after trying out Xubuntu 7.04 Any opinions on Xubuntu? I am going to try it out on a 633Mhz Intel EMachine. Doorstop material but not for LINUX!!
June 26th, 2007 at 4:09 pm
Have a look at FSlint also.
It has functions for cleaning duplicate files,
and a handy interface for removing uneeded packages.
July 31st, 2007 at 5:47 am
Thanks, that was what I needed, forget to write stuff down sometimes. I am running Gutsy and doing pretty well. I had a little problem with a Brother printer driver, I knew the workaround, cause it happened in Feisty. What happens is when dpkg hangs, you can’t install some things. Synaptic, apt, etc.,no frontends will work, the solution is to use sudo gedit /var/lib/dpkg/status and edit out the file(s) that caused the problem and save. As far as I know this is the only way at times –force didn’t work.It took a lot to figure this out and it’s not widely known. It is definately a bug. It’s a really bad one if you don’t know how to fix it. Of course, I knew the half installed package was still there. I had just deleted the log entry so it wouldn’t hang. So, yeah, thanks. One more thing sudo apt-get clean will clear the cache and I think resets the registers.
September 15th, 2007 at 2:52 pm
XLNT guide but I have one question -> At the same time as Deborphan told me everything were gone, KleanSweep noticed a couple of thousand more orphanded files… how is that possible?
September 23rd, 2007 at 5:07 am
It’s also possible to define a custom filter in Synaptic for orphaned packages, instead of installing GTKOrphan. Click Settings > Filters, click New, Deselect All, and check the box next to “Orphaned”. Give the new filter a name, and click OK.
June 18th, 2008 at 5:50 pm
btw, xubuntu hardy(not sure bout all others)
sudo deborphan | xargs sudo apt-get -y remove -purge
Should be
sudo deborphan | xargs sudo apt-get -y remove –purge
Or simply
sudo deborphan | xargs sudo apt-get -y remove -p
Just for those that are new to linux(I am fairly new, few months ago and I would have been confused as to why it didnt work)
August 2nd, 2008 at 7:11 pm
Also kdirstat is available for graphical representation of disk usage if you’re running KDE
September 18th, 2008 at 3:16 am
after sudo apt-get -f install I get this:
Reading package lists… Done
Building dependency tree… Done
Correcting dependencies… Done
The following packages will be REMOVED:
gtkorphan
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0B of archives.
After unpacking 336kB disk space will be freed.
Do you want to continue [Y/n]?
When I abort i habe GtkOrphan under Administration but it doesn’t run. At the same time the update manager gives me:
Software index is broken
It is impossible to install or remove any software. Please use the package manager “Synaptic” or run “sudo apt-get install -f” in a terminal to fix this issue at first.
Any ideas? cheers
September 24th, 2008 at 2:58 pm
Guess I’m a little late to the party, but thanks for posting this. It’s def helpful for those us still digging into *nix!