Posted: . At: 11:44 AM. This was 7 years ago. Post ID: 9923
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

Create a graph of package dependencies with the Linux command line.

There is a way to create a graphical display of the package relations amongst your installed packages on a Debian system. The Graphviz package allows this.

Firstly, install the debtree package.

apt install debtree
apt install graphviz

Then run this command to see all of the package dependencies and relations for the mc package.

debtree mc | dot -Tpng > mc.png

This is what I got when I ran this command, this graph shows the package dependencies for the mc package.

Package dependencies for the mc package.
Package dependencies for the mc package.

This is another example.

┌──[jason@192.168.1.2][~/Documents]
└──╼  ╼ $ debtree sudo | dot -Tpng > mc.png

This prints the package dependencies of the sudo package.

Another way is to use the apt-rdepends package.

Install this package.

apt install apt-rdepends

Then run this command to view a list of dependencies.

┌─[][jason@darkstar][~]
└──╼ $apt-rdepends mc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
mc
  Depends: e2fslibs (>= 1.37)
  Depends: libc6 (>= 2.15)
  Depends: libglib2.0-0 (>= 2.35.9)
  Depends: libgpm2 (>= 1.20.4)
  Depends: libslang2 (>= 2.2.4)
  Depends: libssh2-1 (>= 1.2.5)
  Depends: mc-data (= 3:4.8.15-2)
e2fslibs
  Depends: libc6 (>= 2.17)
libc6
  Depends: libgcc1
libgcc1
  Depends: gcc-6-base (= 6.0.1-0ubuntu1)
  Depends: libc6 (>= 2.14)
gcc-6-base
libglib2.0-0
  Depends: libc6 (>= 2.17)
  Depends: libffi6 (>= 3.0.4)
  Depends: libpcre3
  Depends: libselinux1 (>= 1.32)
  Depends: zlib1g (>= 1:1.2.2)
libffi6
  Depends: libc6 (>= 2.14)
libpcre3
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
multiarch-support
  Depends: libc6 (>= 2.3.6-2)
libselinux1
  Depends: libc6 (>= 2.14)
  Depends: libpcre3
zlib1g
  Depends: libc6 (>= 2.14)
libgpm2
  Depends: libc6 (>= 2.15)
  PreDepends: multiarch-support
libslang2
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
libssh2-1
  Depends: libc6 (>= 2.14)
  Depends: libgcrypt20 (>= 1.6.1)
  Depends: zlib1g (>= 1:1.1.4)
  PreDepends: multiarch-support
libgcrypt20
  Depends: libc6 (>= 2.15)
  Depends: libgpg-error0 (>= 1.14)
libgpg-error0
  Depends: libc6 (>= 2.15)
mc-data

Use apt-rdepends to create a visual map of package dependencies like this.

┌──[jason@192.168.1.2][~/Documents]
└──╼  ╼ $ apt-rdepends --dotty sudo | dot -Tpng > dependency-map.png

This looks very good too, would be great to put on a page advertising a new open-source utility.

The debtree package is the best way though, coupled with the Graphviz package allows good visualization of the actual dependencies of a package. But as usual with Linux, you have a choice.

1 thought on “Create a graph of package dependencies with the Linux command line.”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.