Removing unnecessary packages with deborphan
Posted by Steve on Thu 5 May 2005 at 17:42
Over time most Debian installations acquire packages which are no longer required - they've just been pulled in to satisfy dependencies of software you've since removed. Whilst there are many ways to fix this, the deborphan package is probably the simplest.
deborphan looks for orphaned packages, that is packages which are not required by any other package upon your system.
For example, if you install the game late as follows you'll see that you've pulled in a new package late-data:
root@lappy:~# apt-get install late Reading Package Lists... Done Building Dependency Tree... Done The following extra packages will be installed: late-data The following NEW packages will be installed: late late-data
If you later decide to remove the late package you could do that easily :
dpkg --purge late
But you've left the late-data package upon your system, redundent and orphaned. You could manually remove this, but what about other similar packages you might have lying around, getting needlessly upgraded and wasting disk space?
Enter deborphan. Install it:
root@lappy:~# apt-get install deborphan
Once installed simply run it to display a list of the packages it thinks you don't need upon your system:
skx@lappy:~$ deborphan libsdl-image1.2
(Note that you don't need root privileges to use this tool, it merely reads the installed package lists - it won't remove any packages itself, merely tell you what it thinks you should remove).
As we can see it's decided that the libsdl-image1.2 package isn't required, because no currently installed package depends upon its presence.
There are some other options you can give to the command, which increase it's ability to spot things. These are the "--guess-foo" options. By default it will only list packages which are in the libraries section of the Debian archive, as these are the most likely candidates for removal.
In addition to showing removable library packages it allows you to display potentially orphaned data packages:
skx@lappy:~$ deborphan --guess-data late-data
The manpage shows this option as well as other "guessing" options, and you can read it by invoking:
man deborphan
If you wish to see all the packages which aren't required you could run:
skx@lappy:~$ deborphan --guess-all libxpm-dev libxp-dev xprt-xprintorg libxrandr-dev libxtst-dev pm-dev late-data libjpeg-progs libxmuu-dev libxtrap-dev libhtml-parser-perl libxmu-dev
Most of the packages it reports are development packages, not required per se, but required if you wish to build things from source and link against package libraries.
As with most common jobs in Debian there are alternative methods of cleaning up your system, such as the cruft package.
Additionally some of the package managers such as aptitude and dselect allow you to handle orphaned packages - but I've always thought deborphan was a very underated tool!
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Because deborphan requires no setup phase I've always found it simpler to use.
Still each to their own - and like I said there are a few different ways of doing the same job! Steve
-- Steve.org.uk
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Yes.
Steve
-- Steve.org.uk
[ Parent | Reply to this comment ]
apt-get remove $(deborphan |grep -v shellutils |grep -v textutils)
[ Parent | Reply to this comment ]
Cheers
Julien
[ Parent | Reply to this comment ]
apt-cache show and apt-cache showpkg should give you good information about most packages.
Personally, I use and recommend deborphan. There, too, you don't have to make every decision immediately. See what commands you have at hand. I also turn on negative orphaning so it will keep removing packages that might come and go (some libraries and headers mostly).
[ Parent | Reply to this comment ]
[ Send Message | View Serge's Scratchpad | View Weblogs ]
apt-get remove `deborphan`
for this purpose.
--
Serge van Ginderachter
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
deborphan | xargs apt-get remove -y
[ Parent | Reply to this comment ]
Clément.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
works fine :]
[ Parent | Reply to this comment ]
Or:
dpkg --purge `deborphan`
[ Parent | Reply to this comment ]
is faster ;)
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
I think from looking at the cruft bug page it looks more neglected than perfect.
That's a shame, it's a long while since I used it but I do remember liking it at the time.
Steve
-- Steve.org.uk
[ Parent | Reply to this comment ]
[ Send Message | View sabin's Scratchpad | View Weblogs ]
greets
./sabin -s
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
That's the intention, yes.
Althought it does make sense to look at the list and just check it first - in case it make some mistake.
Steve
-- Steve.org.uk
[ Parent | Reply to this comment ]
[ Send Message | View sabin's Scratchpad | View Weblogs ]
./sabin -s
[ Parent | Reply to this comment ]
is a good alternative to
dpkg --purge packageX
is will remove (and purge) packages that require packageX.
[ Parent | Reply to this comment ]
Aptitude does it.
Just start using aptitude instead of apt-get. It can look exactly like apt-get from the command like, but it also has a curses UI mode that is very nice.
This link gives nine reasons to use aptitude instead of apt-get or dselect. IMHO, apt-get should be retired in favor of aptitude. It's just awesome.
http://lists.debian.org/debian-user/2004/04/msg11344.html
[ Parent | Reply to this comment ]
Aptitude is it.
[ Parent | Reply to this comment ]
deborphan man "says" that the tool invoked without any
options searchs orphaned packages _only within_ the libs
and oldlibs sections. I think it's important notice
information. Could you, please, add it?
Regards!
P.
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Thanks for the suggestion, I hope this updated version is better for you?
Steve
-- Steve.org.uk
[ Parent | Reply to this comment ]
Regards!
P.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Thanks for taking the time to do this again, it's definitely appreciated.
I hope your users are greatful :)
Steve
-- Steve.org.uk
[ Parent | Reply to this comment ]
for me :)
My users don't send me free beer, but they will get next
your articles soon :D
P.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
- libgcrypt1
- libtasn1-0
- libident
- libavcodec1
- libavcodec2
- liba52-0.7.4
- libfame-0.9
- libnfsidmap1
- libxmltok1
but using my preferred package management frontend of synaptic, I click on "custom", and there is no "orphaned".
Being somewhat familiar with how synaptic works, nothing appears under "orphaned" because synaptic doesn't see anything orphaned (that's how it works with the other options at least).
And while we're at it, taking a look at one of my servers (where space is extremely tight, a former Mepis install that has been apt-get updated and apt-get upgraded to debian-sarge for the past year, with everything Mepis I'm aware of removed, and yes, I have X installed, I need Mozilla composer, konqueror and other X apps on the box from time to time), deborphan shows: - libgtkspell0
- libhk-classes-mysql
- libid3-3.8.3
- libhk-classes6
- libhowl0
- libflac++2c102
- dbus-glib-1
- libavcodec1
- libgdk-pixbuf2
- termcap-compat
- libgtkmm2.0-1c102
- libdns11
- libkeynote0
- j2re1.4
- libqt3-i18n
- libtiff3g
- libieee1284-3
- libgnet2.0-0
- libarts1-audiofile
- libexif9
- libcurl2
- libijs-0.35
- libmysqlclient10
- libgssapi1-heimdal
- libpisock8
- lesstif1
- libreiserfs0.3-0
- libzvt2.0-0
- libwxgtk2.5.3
- libtag1
- libgnutls7
- libwxgtk2.4
- libmimelib1a
- plib1.8.3
- libmyspell3
- libneon23
- libnet0
- libstlport4.6
- libgnutls10
but nothing under "orphaned" (although I have a long list under "broken" which I'm thinking is because I have something missing from my sources list which I'm checking now, the packages listed in broken are up to date, nothing gets fixed with "fix broken packages", and everything is working ok).
So other than googling, any shortcuts to finding out whether its ok to remove all the packages above?
The desktop, I see libavcodec1, libavcodec2, aren't these part of the mplayer install? (mplayer happens to update/upgrade against all, stable, testing, unstable so I get the latest codecs and mplayer packages)
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Find the list of removed packages by running:
COLUMNS=200 dpkg --list |grep ^r
Or just their names:
COLUMNS=200 dpkg --list |grep ^r | awk '{print $2}'
[ Parent | Reply to this comment ]
aptitude purge `deborphan [--guess-all]`
several times, as removed packages may leave some more packages orphaned...
keep up the good work!
[ Parent | Reply to this comment ]