Cleaning up a Ubuntu GNU/Linux system
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(local or obsolete)
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
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
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
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 :
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
Once it opens you should see similar to the following screen
removing all the gz files doesn’t just logs being removed watch it..
And I thought I knew everything there was to know about this subject…well, now I do – nice post. Charlotte Bell @ Flyttst?dning
Spot on – thanks, really useful!
Which directory is safe to delete manually? I’m new to Linux, so please be specific 🙂
You should probably not delete a directory manually if you are new to Linux, that can cause a lot of trouble.
Thank You… Nice post…
I am newbie and I looking for this.
thank you 🙂
I tried to remove, thanks for the tips, but still on my EeePC-900 with 4GiB devoted to Linux system I fall short of memory (-200MB left). I remember when I fitted AmigaOS in 4 FD and Win3.1 in 50 MB. Here it makes me question why normal 4 GB are not enough?? I keep all the downloaded files in a separate directory on the 16 GiB Windows disk. Is there a way to removeall the old files, installs without the hard picking what? The tips didn’t clean a lot, just a 100 MB, and the system doesn’t have just the basic things.
P.S. I added .thumbnails directory into the cleaning routine! I’d like to add more, just fell short of ideas.
I was looking for something like that.
Is there any chance you can post come tutorial about optimizing files, and optimizing memory – basically keeping ubuntu cleen and tidy ?
A superb post. I was looking for something like this to help me clean my Ubuntu 9.10
Thanks for the post. It is really helpful both to learn and use!!
If you do regular updates, you may want to clean out old kernels (they kept accumulating). Do a
to see all installed kernels. You can remove the old ones with
sudo apt-get remove linux-images-WHAT-EVER-YOUR-VERSION-IS
If you also have installed the kernel sources, you may want to remove them as well. You see the installed kernel sources in
If you have multiple kernel sources to remove (as I had) you can remove all of them like that (your command will most certainly have to look different!)
sudo apt-get remove linux-headers-2.6.28-1
This cleaned up over 600MB… 😉
debfoster = nice
I have just used the synaptic package manager to delete orphaned files, as I am fairly incompetent in the inner workings of ubuntu, I deleted the first set of orphaned files and then some more after.
I seem to have deleted libraries for the shoutcast plugin and also rubyripper is no longer working.
Is there a way of recovering the lost files?? I have tried reinstalling the shoutcast plugin but to no avail.
Just the info I needed to keep my PC lean and clean 🙂
Hey this comlilation contains some info wich can harm your system and nothing of it mentioned here…be careful
well gtkOrphan seemed to be doing a good job on Natty .. until it deleted all linux kernels & headers … fresh install methinks 🙂 …
Many thanks for your job!
Tis is completely useless because:
1. How can you remove “not installed (residual config) packages if they are nor installed”. If you do what you say you will install all the residual packages that you don’t have installed.
2. You don’t explain what the “Remove partial packages” operation will do on the reader’s system. Partial?? I didn’t know there were packages that are partial and ones which are not.
3. Localepurge: “Please note, that this tool is a hack which is *not* integrated with Debian’s package management system and therefore is not for the faint of
heart. This program interferes with the Debian package management and does provoke strange, but usually harmless, behaviour of programs related
with apt/dpkg like dpkg-repack, debsums, reportbug, etc. Responsibility for its usage and possible breakage of your system therefore lies in
the sysadmin’s (your) hands.”
4. You say: “If you want to remove orphaned packages you need to install deborphan package.”
Almost everybody that knows what an orphaned package is, knows how to remove them or can easily learn it from his own system. You should start explaining what is an orphaned package, why would you want to remove it (pros and cons).
5. For many people it would be better to install gtkorphan from the ubuntu uniiverse/admin repositories with:
$sudo aptitude install gtkorphan
gtkorphan is just a front end to deborphan, so it won’t do different things to find the orphaned packages.
6 . Don’t say: “For a complete list of available commands increase the level of verbosity of the help command”
Say more with less words. For example: “wajig –help -v” (or whatever) increments the verbosity of ….
Thanks! Great instructions!
1.“not installed (residual config) packages” are packages that you installed in the past but you have removed now but still leaving the configuration files.
2. partial packages are dependencies that are not used again because the main package that used it already removed.
Can I get this article as PDF og other, as a mail, from You?
Still works. Thanks.