How to display package dependencies

Display dependencies to inspect which packages are required for given application.

Use apt-cache utility to display package dependencies

Display dependencies for particular package located in configured repository.

$ apt-cache depends tmux
tmux
  Depends: libc6
  Depends: libevent-2.0-5
  Depends: libtinfo5
  Depends: libutempter0

Recursively display dependencies for particualar package located in configured repository.

$ apt-cache depends --recurse tmux
tmux
  Depends: libc6
  Depends: libevent-2.0-5
  Depends: libtinfo5
  Depends: libutempter0
libc6
  Depends: libgcc1
  Breaks: <hurd>
  Breaks: libtirpc1
  Breaks: locales
  Breaks: locales-all
  Breaks: <lsb-core>
  Breaks: nscd
  Suggests: glibc-doc
 |Suggests: debconf
  Suggests: <debconf-2.0>
    cdebconf
    debconf
  Suggests: libc-l10n
  Suggests: locales
  Replaces: <libc6-amd64>
libevent-2.0-5
  Depends: libc6
libtinfo5
  Depends: libc6
[...]

There is too much information in the above example, but it can be easily limited.

$ apt-cache depends --no-recommends --no-suggests --no-replaces --no-conflicts --no-breaks tmux | awk '{print $NF}' | xargs apt-cache depends
tmux
  Depends: libc6
  Depends: libevent-2.0-5
  Depends: libtinfo5
  Depends: libutempter0
libc6
  Depends: libgcc1
  Breaks: <hurd>
  Breaks: libtirpc1
  Breaks: locales
  Breaks: locales-all
  Breaks: <lsb-core>
  Breaks: nscd
  Suggests: glibc-doc
 |Suggests: debconf
  Suggests: <debconf-2.0>
    cdebconf
    debconf
  Suggests: libc-l10n
  Suggests: locales
  Replaces: <libc6-amd64>
libevent-2.0-5
  Depends: libc6
libtinfo5
  Depends: libc6
  Breaks: dialog
  Replaces: libncurses5
libutempter0
  Depends: libc6

Use aptitude utility to display package dependencies

Install a high-level interface to the package manager.

$ sudo apt-get install aptitude

Display dependencies for particular package located in configured repository.

$ aptitude show tmux | grep ^Depends
Depends: libc6 (>= 2.14), libevent-2.0-5 (>= 2.0.10-stable), libtinfo5 (>= 6), libutempter0 (>= 1.1.5)

Use apt-rdepends utility to display package dependencies

Install an utility that performs recursive dependency listings similar to apt-cache.

$ sudo apt-get install apt-rdepends

Display dependencies for particular package located in configured repository.

$ apt-rdepends --print-state tmux --state-follow=none
tmux
  Depends: libc6 (>= 2.14) [Installed]
  Depends: libevent-2.0-5 (>= 2.0.10-stable) [Installed]
  Depends: libtinfo5 (>= 6) [Installed]
  Depends: libutempter0 (>= 1.1.5) [Installed]

Recursively display dependencies for particualar package located in configured repository.

$ apt-rdepends --print-state tmux
Reading package lists... Done
Building dependency tree       
Reading state information... Done
tmux
  Depends: libc6 (>= 2.14) [Installed]
  Depends: libevent-2.0-5 (>= 2.0.10-stable) [Installed]
  Depends: libtinfo5 (>= 6) [Installed]
  Depends: libutempter0 (>= 1.1.5) [Installed]
libc6
  Depends: libgcc1 [Installed]
libgcc1
  Depends: gcc-6-base (= 6.3.0-18) [Installed]
  Depends: libc6 (>= 2.14) [Installed]
gcc-6-base
libevent-2.0-5
  Depends: libc6 (>= 2.17) [Installed]
libtinfo5
  Depends: libc6 (>= 2.16) [Installed]
libutempter0
  Depends: libc6 (>= 2.4) [Installed]

Use dpkg utility to display package dependencies

Display dependencies for particular Debian binary package.

$ dpkg --info /var/cache/apt/archives/tmux_2.3-4_amd64.deb | grep ^\ Depends:
 Depends: libc6 (>= 2.14), libevent-2.0-5 (>= 2.0.10-stable), libtinfo5 (>= 6), libutempter0 (>= 1.1.5)

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system.