Deborphan is a tool that finds packages that have no packages depending on them. Its primary goal is to trace unused libraries. The default operation is to search only within the libs and old-libs sections to detect unused libraries. After scanning your system with deborphan it will show you a list of packages which has no dependencies or is no longer required. Deborphan can be run from the terminal but has also a GUI (gtkorphan). Below you find a how-to for using Deborphan in a terminal and with the GUI.
Be noticed that deborphan is a very powerful tool which is not really meant for new users who does not have sufficient knowledge of Linux!
Deborphan in a terminal:
First we need to install deborphan:
Open a terminal
Type the following command:
sudo apt-get install deborphan
Follow the instructions given in the terminal
Do not close the terminal
When deborphan is installed we can start using it. First we start of with a dry run to find out which packages we don't need. The command below will show a list of packages which can be removed by deborphan:
deborphan --guess-all
With the command above deborphan can try to guess what packages may not be of much use to you by examining the package's name and/or description. It will pretend the package is in the main/libs section, and report it as if it were a library. This method is in no way perfect or even reliable, so beware when using this!
Now we can remove unnecessary data packages by running the following command in the terminal:
sudo deborphan --guess-data | xargs sudo aptitude -y purge
To delete unnecessary libraries run the following command in the terminal:
sudo deborphan | xargs sudo apt-get -y remove --purge
Running both commands will take some time. Do not close the terminal or interrupt the cleaning process.
When running the command deborphan --guess-all again, a new list will probably generated. The reason for this is that we removed unnecessary packages who has dependencies themselves which also aren't need any longer. Run the last two commands untill the 2nd command doesn't give any output. This might take some time to get everything clean.
Deborphan with a GUI:
Deborphan can also be run with a GUI, namely: Gtkorphan. GtkOrphan (a Perl/Gtk2 application for Debian systems) is a graphical tool which is a GUI front-end for deborphan, adding the package-removal capability.
Gtkorphan can be installed by running the following terminal command:
Open a terminal
Type the following command:
sudo apt-get install gtkorphan
Follow the instructions in the terminal
After installation, close the terminal
After installation, the tool GtkOrphan be found here:
Menu > Administration > Remove orphaned packages
The menu is very simple, there are 2 tabs:
Orphaned packages
Non-orphaned packages
The first tab shows all found orphaned packages which can be deleted since they are no longer needed while the second tabs shows all non-orphaned packages which are needed by your system and therefore should not be deleted since this will break down your installation.
This how-to will only cover the first tab and the Options section at the bottom of the tabs.
To remove unnecessary packages which aren't no longer needed, just select those packages by clicking on the checkbox. When this application is started up for the first time, this will be a long list. But all files can be checked for removal safely.
Be aware that also packages will be listed who doesn't have any dependencies but are installed. Packages like gparted or ubuntu-desktop, wine as example will show up in the list as they are "top-level" packages and no other package depends on them. When such package appear in the list, just right-click on that package and select hibernate to mark them as not being an orphaned package so you keep that package. You can access and modify the hibernation list as you want, from the View menu.
In the main window, expand the "Options" section and check the "Show all orphan packages, not only those in the libs section" checkbox. This option also shows all orphaned packages which can be removed.
1. Tab Orphaned packages
2. Tab Non-orphaned packages
3. Options section expanded