DEV Community

Cover image for Easily Visualize Debian Package Dependencies with debtree
kojix2
kojix2

Posted on

Easily Visualize Debian Package Dependencies with debtree

Introduction

Sometimes you might want a quick and easy way to visualize and understand which packages a given package depends on. With the debtree package and graphviz, you can do this in just a few steps.

Installation

Install both debtree and graphviz:

apt install debtree graphviz
Enter fullscreen mode Exit fullscreen mode

Visualizing dependencies

If you can specify the package name you want to visualize:

dpkg -l | grep ufw # Check if it exists
Enter fullscreen mode Exit fullscreen mode

You can easily visualize the packages it depends on:

debtree ufw | dot -T png -o ufw_deps.png
Enter fullscreen mode Exit fullscreen mode

ufw_deps.png

Here, I specified -T png to output a PNG image for embedding in Qiita, but you can choose from many other formats like svg.
If you have a desktop environment, you can also visualize it instantly using x11:

debtree ufw | dot -T x11
Enter fullscreen mode Exit fullscreen mode

ufw_x11.png

Visualizing reverse dependencies

To visualize reverse dependencies, you can use the -R / --show-rdeps option.

However, using -R alone will also display many packages that are not actually installed on your system.
For a cleaner view, add the -I / --show-installed option to limit the output to installed packages only:

debtree -R -I iptables | dot -T x11
Enter fullscreen mode Exit fullscreen mode

From this, you can see that docker-ce and ubuntu-standard depend on iptables.

iptables_reve_deps

That’s it for today!

Top comments (0)