Software

How to check package dependencies with apt-rdepends

Ever wonder what dependencies a piece of software requires, or what software depends upon a package? If so, look no further than apt-rdepends. Here's how to use this handy tool.

linuxhero.jpg
Image: Jack Wallen

How many times have you hesitated to install an application on a debian-based Linux distribution simply because you weren't sure of what dependencies the application might install. Maybe that hesitation is because you're dealing with a server and you can't risk installing a dependency that might wreak havoc on your running services. Regardless of the reason, there is a tool that enables you to find out exactly what dependencies an application will require without having to install the application—that tool is apt-rdepends. I'm going to walk you through the process of installing and using apt-rdepends, so you know exactly what will be installed on your desktops and servers, before you run apt install.

The apt-rdepends tool searches through the APT cache to locate dependencies for an application, and knows how to emulate the results. By default, apt-rdepends will display a listing of every dependency a package has, and recursively lists the dependencies of the dependencies.

The apt-rdepends software can be installed on any modern Debian-based Linux distribution. I'll be demonstrating on Ubuntu 17.10.

Installation

Fortunately, rdepends can be found in the standard repositories, so the software can be installed, out of the box. To install apt-rdpends, open up a terminal window and issue the command:

sudo apt install apt-rdepends

Once the installation completes, you're ready to start using the tool.

Usage

Using apt-rdpends is quite simple. The syntax of the command is:

apt-rdepends [options] [packages]

Let's say you want to find out the dependencies of php. For that you could issue the command:

apt-rdepends php

The output for the above command (Figure A) will be quite lengthy, as will most outputs from apt-rdepends.

Figure A

Figure A

Checking the dependencies for php.


You can also reverse this and find out what packages depend upon the package in question. Say, for example, you want to know what packages depend upon php. For this, you would issue the command:

apt-rdepends -r php

The output of the above command (Figure B) will not only list out those apps that are dependent up the package in question, but the dependencies of those dependent apps.

Figure B

Figure B

Reversing the output to find out what apps are dependent on php.


Visual map

Here's a really cool trick. With the help of the dot command, you can generate a visual map of the dependencies. Before you do this, you must first install the graphviz tool, with the command:

sudo apt-install graphviz

Once that's installed, you can generate a visual map by piping the output of the apt-rdepends command to the dot command, like so:

apt-rdepends --dotty php | dot -Tpng > php-dependencies.png

The —dotty option takes a list of packages and generates output suitable for use by springgraph, which can then be used by the dot command. The end result will be a sizable map of dependencies (Figure C).

Figure C

Figure C

Our map is clearly too large to display without scrolling.


And that's it for using apt-rdepends.

A handy way of knowing what's needed

If you've ever wanted to know what dependencies a package will install or what other software depends upon a package, you won't find an easier method than apt-rdepends. It's a simple tool that can offer some very important data. Give it a go and see if you don't find yourself in a state of dependency.

Also See

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.

Editor's Picks

Free Newsletters, In your Inbox