deborphan: find packages you don’t want

October 21st, 2007 edited by paulgear

Article submitted by James Cameron. Please help DPOTD by submitting good articles about software you like!

If you’ve been reading debaday for a while, chances are you now have a heap of packages installed that you’ve tried out, some of which you want to keep installed, and some of which you have forgotten.

Those forgotten packages can cost you. They might contain setuid binaries or running daemons that could compromise your security. Future upgrades take longer, and there will be more to download. Your backups have grown. You are doing backups, right? That’s what duplicity was for.

If you’ve been using aptitude to install packages, then the autoclean command will remove a few things you don’t want.

An example using deborphan on a Debian Etch system:

# deborphan

In this example, deborphan discovered two fairly small packages that were superfluous, and so they can be removed. Since deborphan gives you only package names in this mode, they can be used in a command:

# aptitude purge `deborphan`

Or if you are in the habit of working at a level below aptitude:

# dpkg --purge `deborphan`

Recursive Deborphan

What you remove may reveal something else as newly orphaned. You
might even want to do this recursively:

while [ -n "`deborphan`" ]; do
    aptitude purge `deborphan`

You might call that a deborphan-recursive script.

Not Just Libraries

Deborphan gives you a list of packages installed on your system that no other package depends on. By default this will only show library packages. But it can also be told to give you a list of all such packages using the -a flag … consider this compound command:

# dpkg-query -W --showformat='${Installed-Size} ${Package}\n' \
`deborphan -a | awk '{print $2}'` | sort -rn

You might name this deborphan-by-size. What it does is give you a sorted list of packages that nothing depends on, in descending order by package size. Work down from the top, choosing what you do not want installed. But remember that every time you remove a package, the list might change because the removed package might have dependencies that are now orphaned.

What’s the worst that could happen? You might remove some package that you will have to reinstall and reconfigure. You have backups. [If you have installed any applications without using the Debian packaging system, it's a different story. You will have to manually make sure that the packages deborphan removes are not required for them to operate. Ed.]

Or how about a small system where you have removed as much as possible so that you have the most space available for your own stuff? Deborphan can be used step by step to challenge you to remove packages you don’t really need. Eventually dpkg, apt-get, or aptitude will warn you about removing a package it considers essential. That’s where you stop, unless you really want some trouble.

Sometimes library packages are installed just to satisfy some dependency of a package in development. Developers will find deborphan’s decisions cause them to reinstall packages they need for software development … an answer to that is to either create a metapackage that refers to the packages you need, or to do your package building in a pbuilder.

Deborphan is available in Debian and Ubuntu since before time began.

Posted in Debian, Ubuntu |

16 Responses

  1. Cheetah Says:

    An awesome helper program that comes with deborphan is orphaner. The orphaner script (which accepts all the options deborphan does, at least as far as what kinds of packages to consider) provides a dialog wrapper around deborphan, showing you what packages deborphan found, and letting you select ones to remove. After removing packages, it will run deborphan again and show you what packages were newly found to be orphaned, and what previously found packages are still installed.

  2. mitch Says:

    If you’re using aptitude right from the start, its “this package has been automatically installed” dependency handling should prevent having orphaned packages. If you remove the last package that depends on some other package, the other package will be removed as well.

  3. Jes Andersen Says:

    Very unless when I tested it. Both because of aptitude function mitch tells us about, and more importantly it had a lot of false positives for me, and broke my dvd playback so I’m not impressed. I’ll rather use Mark auto in aptitude

  4. paulgear Says:

    I agree about using aptitude to manage your dependencies - it will mitigate the need for deborphan a lot of the time.

    Jes: deborphan definitely should not break the Debian packages on your system - i’m sure the maintainer would be interested in a bug report if your problem is one that can be reproduced.

  5. i5513 Says:

    Use aptitude !

    Debian Rocks!

  6. James Says:

    Man, I love me some aptitude, but it gets pretty frustrating when you use e.g. KnoppMyth and some of your basic packages have a laundry list of very specific dependencies. After about a month from the release of a new build, I always find dependency conflicts that prevent me from installing anything new. I’ll try to install a game or the latest IceWeasel/Firefox, and find out that mythtv-base depends on libc a.b.c, while Firefox depends on libc a.b.d, and I’m just up a creek.

    Now, if somebody could come out with a tool to fix *that*, I’d be right on board.

  7. Biga Says:

    Wow, thank you! I just thought it would be good to find something like this few days ago! You’re reading thoughts. =)

  8. Marius Scurtescu Says:

    “Jes: deborphan definitely should not break the Debian packages on your system - i�’m sure the maintainer would be interested in a bug report if your problem is one that can be reproduced.”

    Hm, I am not so sure.

    Among other libraries, the follwing were listed on my system:
    - gstreamer0.10-pitfdll
    - gstreamer0.10-plugins-bad-multiverse
    - gstreamer0.10-plugins-ugly-multiverse
    - gstreamer0.8-ffmpeg
    - gstreamer0.8-plugins-multiverse
    - sun-java6-javadb

    I definitely don’t want to remove these, and this could be why Jes had problems with DVD palyback.

  9. i5513 Says:

    #7 I think that it will be a KnoppMyth issue. I don’t know how KnoppMyth repositories works

  10. Syngin Says:

    One thing I’m curious about, what if you have packages compiled from source that rely on the ‘orphaned’ packages?

  11. paulgear Says:

    Syngin: That’s what the [Ed.] comment above is about. If you haven’t installed from a package, there’s no way deborphan can know about the dependency, and it will assume the orphaned package is unused.

  12. saato Says:

    It found:


    I hope they were not important… ;)

  13. Ivan Says:

    Some years ago I wrote a toy app for learning Python with a very similar functionality as Deborphan. The main difference is that when package names are provided as command-line arguments, my app shows a list of *would-be* orphaned packages, *without actually needing to remove them*. Then you append the listed packages to the command-line, rinse and repeat until you have enough.

    I guess the code will be quite shameful today, but I’m still using it very frequently and it really does its job. I always envisioned an orphaner-like UI for it, but never started it (maybe I should rewrite the app first). If you’re interested in it:

  14. Ivan Says:

    Sorry, the right URL for LeafPkgs is

  15. mish Says:

    Another use for deborphan is to to generate a list of packages you have chosen to install. While you can do this using

    $ sudo dpkg -l

    that produces rather a long list. If you use the deborphan with the -a option, you get a list of all packages that no other package depends on. And if you use the –no-show-section flag, you can pipe this into xargs apt-get install -y to reinstall all your applications.

    I use this when doing a clean reinstall. To make it clearer, here it is step by step.

    1. Record your package list

    $ deborphan -a –no-show-section > my-package-list.txt

    2. After reinstall a clean system, reinstall all your packages

    $ cat my-package-list.txt | sudo xargs aptitude install -y

    If you want to maintain a list for use on several computers, you could put comments in, using a # on the line of the comment. Then you can install with

    $ grep -v ‘#’ my-package-list.txt | sudo xargs aptitude install -y

  16. Johannes Says:

    There is a GUI frontend to deborphan called gtkorphan.
    Thanks for this article!