Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to be able to output a list of all the dependencies of an installed package, including the version numbers of the dependencies that I have installed.

share|improve this question
up vote 1 down vote accepted

If you need a customized output, it could be a good option to implement a script to accomplish this task using python-apt:

import argparse
from itertools import chain
from collections import deque
import apt

def main(args):
    packages_seen = set()
    dependencies = deque()

    def print_package(package):
        print, package.installedVersion

        or_dependencies = [dependency.or_dependencies
                           for dependency in package.installedDependencies]

    cache = apt.cache.Cache()
    package = cache[args.package_name]

    while dependencies:
        dependency = dependencies.popleft()
        package_name =

        # Skip virtual packages                                                                                                          
        if package_name not in cache:

        if package_name not in packages_seen:
            package = cache[]

if __name__ == '__main__':
    parser = argparse.ArgumentParser('Print all package dependencies '
                                     'and their installed version')
    parser.add_argument('package_name', help='Package name')
    args = parser.parse_args()


Example output:

$ python sqlite
sqlite 2.8.17-6.1ubuntu1
libc6 2.13-20ubuntu5
libreadline6 6.2-2ubuntu1
libsqlite0 2.8.17-6.1ubuntu1
libc-bin 2.13-20ubuntu5
libgcc1 1:4.6.1-9ubuntu3
tzdata 2011n-0ubuntu0.11.10
readline-common 6.2-2ubuntu1
libtinfo5 5.9-1ubuntu5
multiarch-support 2.13-20ubuntu5
gcc-4.6-base 4.6.1-9ubuntu3
debconf 1.5.40ubuntu1
install-info 4.13a.dfsg.1-8ubuntu1
perl-base 5.12.4-4
libbz2-1.0 1.0.5-6ubuntu1
libselinux1 2.0.98-1.1
zlib1g 1:
coreutils 8.5-1ubuntu6
xz-utils 5.0.0-2
libacl1 2.2.51-3
libattr1 1:2.4.46-3
liblzma2 5.0.0-2
share|improve this answer
Thanks jcollado, that's perfect. I noticed that it's a recursive script, grabbing the dependencies of the dependencies as well, but they were sorted in a way that made it easy to isolate only the first-level dependencies. Thanks! – Jay Dec 12 '11 at 23:22

use apt-cache

Using firefox as an example :

apt-cache showpkg firefox | less

to quit less type q. I piped it to less as the output can be long. You can pipe it to a file if you wish.

To show your installed packages, use dpkg

dpkg -l
dpkg -l | grep firefox
share|improve this answer

I normally use rdepends for that, install it with sudo apt-get install apt-rdepends or look for in the Ubuntu Software Center.

After installing the program you can use it simply by opening a terminal and typing sudo apt-rdepends <package_name>.

It will show you all the dependencies any package that is in your apt lists required to install and all the dependencies of a package that you might be thinking about installing.

It shows the information in a tree diagram where all the dependencies from one package are compared against all the dependencies of the each package dependency... (and so).


sudo apt-rdepends sqlite

Reading package lists... Done
Building dependency tree       
Reading state information... Done
  Depends: libc6 (>= 2.4)
  Depends: libreadline6 (>= 6.0)
  Depends: libsqlite3-0 (>= 3.6.18)
  Depends: libc-bin (= 2.13-20ubuntu5)
  Depends: libgcc1
  Depends: tzdata
  Depends: gcc-4.6-base (= 4.6.1-9ubuntu3)
  Depends: libc6 (>= 2.2.4)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.13-0ubuntu6)
  Depends: debconf (>= 0.5)
  Depends: debconf-2.0
  PreDepends: perl-base (>= 5.6.1-4)
  PreDepends: dpkg (>= 1.14.20)
  PreDepends: libc6 (>= 2.11)
  PreDepends: coreutils (>= 5.93-1)
  PreDepends: libbz2-1.0
  PreDepends: libc6 (>= 2.11)
  PreDepends: libselinux1 (>= 1.32)
  PreDepends: xz-utils
  PreDepends: zlib1g (>= 1:1.1.4)
  PreDepends: libacl1 (>= 2.2.11-1)
  PreDepends: libattr1 (>= 2.4.41-1)
  PreDepends: libc6 (>= 2.7)
  PreDepends: libselinux1 (>= 1.32)
  Depends: libattr1 (>= 2.4.41-1)
  Depends: libc6 (>= 2.4)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.4)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.8)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.4)
  Depends: libc6 (>= 2.7)
  Depends: liblzma2 (>= 5.0.0)
  Depends: libc6 (>= 2.4)
  Depends: libc6 (>= 2.4)
  PreDepends: multiarch-support
  Depends: libc6 (>= 2.11)
  Depends: libtinfo5 (>= 5.6+20070908)
  Depends: readline-common
  Depends: libc6 (>= 2.4)
  Depends: dpkg (>= 1.15.4)
  Depends: install-info
  Depends: libc6 (>= 2.4)
  Depends: libc6 (>= 2.4)
  PreDepends: multiarch-support

After that if you want to see if the package is installed in your system simply use this command

dpkg-query -l <package_name>

It will show you if the package is installed, ie

dpkg -l firefox

ii  firefox        8.0+build1-0ub Safe and easy web browser from Mozilla

The ii in front of the package means that its installed.

share|improve this answer
It looks like this just lists dependencies without telling you whether you have them installed. Is that right? – Jay Dec 12 '11 at 20:01
Correct, so it also means that you can check if a dependency is installed in your system for a package that you have not yet installed. I have added the method to check the status of a package in your system. – Bruno Pereira Dec 12 '11 at 21:32

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.