To visualize package dependency relationship in Linux is one attractive feature. This article will show how to do that in Debian OS.
Create DOT file by apt-cache
The command apt-cache
has one sub-command dotty
which is able to take a list of packages on the command line and generates output suitable for
use by dotty from the GraphViz package.
apt-cache dotty docker-ce > docker-ce.dot
Convert DOT file to graph file
The command dot
can convert DOT file to different graph file formats.
dot -Tjpg docker-ce.dot > docker-ce.jpg

To avoid large graph
In default, apt-cache dotty
will trace out all dependent packages and produce a very large graph DOT file. To limit the output to only the packages listed on the command line, set the APT::Cache::GivenOnly
option in apt.conf file (/etc/apt/apt.conf).
Note: need root permission to edit apt.conf file.
APT
{
// Options for apt-get
Get
{
Download-Only "false";
};
Cache
{
GivenOnly "true";
}
};
That’s it and hope it’s helpful for you.
Thanks and happy reading!