Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

This question is similar to How can I find out why a package was installed?, but in my case I'd like to know before actually installing a package, why it will install a particular dependency.

So for example I might run

sudo apt-get install superfoo

and the output will say something like:

The following extra packages will be installed:
  foo bar baz ... libderp libjunk

And this might be a really huge list. In some instances I'll see something that is going to be installed that doesn't really make sense to me given what I'm installing, so I want to know why that particular dependency is going to be installed.

In the above example let's say I'd like to understand why libderp would get installed. I know that somehow there is a chain of dependencies between superfoo and libderp but the huge list of packages to be installed makes it hard to see what this chain is.

Once I know the dependency chain, I can decide whether I really want to install the original package or not, and/or whether I should get in touch with the maintainer of that package to see if they really need to have those dependencies there.

share|improve this question
If someone's answer was helpful to you, then please consider marking it as the accepted answer so others may more easily find it in the future. This is also a polite way to thank the person answering your question for helping you out. – Danatela Apr 15 '14 at 7:56

3 Answers 3

There may be an easier way to do this, but it can be done if you use reverse-depends. You will need to install the ubuntu-dev-tools package by doing

apt-get install ubuntu-dev-tools

Or by clicking this button:

Install via the software center

Once installed, you can then use reverse-depends to see what depends on a specific package. For example, if you try to install something that wants to install a bunch of extra packages and you want to see why "libsmpeg0" is being installed, you run

reverse-depends libsmpeg0

Which would output the following.

* sandboxgamemaker

* btanks
* fenix-plugin-mpeg [armel armhf i386 powerpc]
* fillets-ng
* gltron [amd64 armel i386 powerpc]
* libalien-sdl-perl
* libsdl-perl [i386]
* libsmpeg-dev
* libtaoframework-sdl1.2-cil
* python-pygame
* ruby-sdl
* sdlbrt
* smpeg-gtv
* smpeg-plaympeg
* tdfsb

Packages without architectures listed are reverse-dependencies in: amd64, armel, armhf, i386, powerpc

Take a look and see if the package you want to install is in that list. If not, then another one of the packages that is being pulled in during that initial install will show up in that list, and you will need to run reverse-depends on that package. Eventually you will see the initial package you want to install in that list. At that point, you should have a chain showing exactly why that package was installed.

As an added note, I believe recommends is on by default, so if something is set as a recommends it will get pulled in to. Suggests if off, but reverse-depends can show that info as well.

share|improve this answer
While I'm sure this answer would work, it personifies the issue the OP is trying to avoid. ubuntu-dev-tools results in the following packages being installed. bzr bzr-builddeb dctrl-tools debian-archive-keyring debian-keyring debootstrap devscripts diffstat distro-info distro-info-data dput genisoimage gettext hardening-includes intltool-debian libapt-pkg-perl libarchive-zip-perl libasprintf-dev libassuan0 libauthen-sasl-perl libautodie-perl libclone-perl libcommon-sense-perl libcroco3 libdigest-hmac-perl libdistro-info-perl libemail-valid-perl libencode-locale-perl liberror-perl – Fake Name Apr 15 '14 at 7:38
[continued] python-launchpadlib python-lazr.restfulclient python-lazr.uri python-oauth python-paramiko python-reportbug python-secretstorage python-simplejson python-soappy python-support python-wadllib python3-debian python3-magic quilt reportbug t1utils unzip wdiff xdelta (Note: The above was just the required packages from sudo apt-get install ubuntu-dev-tools on a fairly clean ubuntu server instance). If you're trying to avoid installing huge amounts of cruft, this is probably the worst solution possible. – Fake Name Apr 15 '14 at 7:41

What you really seem to be asking is "How do I diagram dependencies?" so you can see which packages pull in which dependencies.

You get both text and diagrammed dependencies from the apt-cache command (included in the apt package, part of the default install).

Here's an example of apt-cache for listing dependencies of the 'hello' package in text format. Text output will always be only one level.

$ apt-cache depends hello
  Depends: libc6
 |Depends: dpkg
  Depends: install-info

You can read the diagram using any dotfile viewer, such as dotty (included in the graphviz package, also part of the default install)

Here's an example of getting the full dependency tree in graphical format, then displaying it. Graphical output will always be the full tree.

$ apt-cache dotty hello > dotfile
$ dotty dotfile

Looking it over, you can see that the 'hello' package pulls in a ton of Perl packages...and which dependency does it.

share|improve this answer
While that would work, it would be some serious work to do it this way to see what was pulling in a certain package if the package was a dependency of a dependency. – tgm4883 May 6 '12 at 23:51
Not at all. Merely look at the dotfile picture. – user535733 Jan 20 '13 at 3:57
apt-cache depends --recurse will give you the full picture, but apt-rdepends below is better because it only follows actual dependencies, not recommended or suggested ones. – mhsmith Feb 23 at 21:33
Although apt-get actually will install recommended dependencies unless you use the --no-install-recommends flag. – mhsmith Feb 23 at 21:49
What does that bar mean? | – CMCDragonkai Sep 21 at 4:52

apt-rdepends does this, without installing 50+ libraries of cruft like ubuntu-dev-tools.

durr@scraper:~$ apt-rdepends mercurial
Reading package lists... Done
Building dependency tree
Reading state information... Done
  Depends: libc6 (>= 2.14)
  Depends: mercurial-common (= 2.8.2-1ubuntu1)
  Depends: python (<< 2.8)
  Depends: ucf (>= 2.0020)
  Depends: libgcc1
  Depends: gcc-4.9-base (= 4.9-20140406-0ubuntu1)
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.3.6-2)
  Depends: python (<< 2.8)
  Depends: python:any (>= 2.7.1-0ubuntu2)
  Depends: libpython-stdlib (= 2.7.5-5ubuntu3)
  Depends: python-minimal (= 2.7.5-5ubuntu3)
  Depends: python2.7 (>= 2.7.5-1~)
  Depends: libpython2.7-stdlib (>= 2.7.5-1~)
  Depends: libbz2-1.0
  Depends: libc6 (>= 2.15)
  Depends: libdb5.3
  Depends: libexpat1 (>= 2.1~beta3)
  Depends: libffi6 (>= 3.0.4)
  Depends: libncursesw5 (>= 5.6+20070908)
  Depends: libpython2.7-minimal (= 2.7.6-8)
  Depends: libreadline6 (>= 6.0)
  Depends: libsqlite3-0 (>= 3.5.9)
  Depends: libssl1.0.0 (>= 1.0.0)
  Depends: libtinfo5
  Depends: mime-support
  Depends: libc6 (>= 2.4)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.17)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.15)
  Depends: libtinfo5 (= 5.9+20140118-1ubuntu1)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.15)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.15)
  Depends: libtinfo5
  Depends: readline-common
  PreDepends: multiarch-support
  Depends: dpkg (>= 1.15.4)
  Depends: install-info
  PreDepends: libbz2-1.0
  PreDepends: libc6 (>= 2.14)
  PreDepends: liblzma5 (>= 5.1.1alpha+20120614)
  PreDepends: libselinux1 (>= 2.1.0)
  PreDepends: tar (>= 1.23)
  PreDepends: zlib1g (>= 1:1.1.4)
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.14)
  Depends: libpcre3
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
  PreDepends: libacl1 (>= 2.2.51-8)
  PreDepends: libc6 (>= 2.17)
  PreDepends: libselinux1 (>= 1.32)
  Depends: libattr1 (>= 1:2.4.46-8)
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.4)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.14)
  PreDepends: dpkg (>= 1.16.1)
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
  Depends: debconf (>= 0.5)
  Depends: debconf-2.0
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
  PreDepends: perl-base (>= 5.6.1-4)
  PreDepends: dpkg (>= 1.14.20)
  PreDepends: libc6 (>= 2.14)
  Depends: dpkg (>= 1.13.20)
  Depends: python2.7-minimal (>= 2.7.5-1~)
  Depends: libpython2.7-minimal (= 2.7.6-8)
  Depends: zlib1g (>= 1:1.2.0)
  PreDepends: libc6 (>= 2.15)
  Depends: libpython2.7-stdlib (= 2.7.6-8)
  Depends: mime-support
  Depends: python2.7-minimal (= 2.7.6-8)
  Depends: coreutils (>= 5.91)
  Depends: debconf (>= 1.5.19)
  PreDepends: libacl1 (>= 2.2.51-8)
  PreDepends: libattr1 (>= 1:2.4.46-8)
  PreDepends: libc6 (>= 2.17)
  PreDepends: libselinux1 (>= 1.32)

On my clean ubuntu server install, apt-rdepends only required libapt-pkg-perl for installation. It's much lighter then ubuntu-dev-tools, and yet is still recursive, so you get all the dependencies, rather then just the first-order dependencies, like apt-cache depends returns.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.