418

In order to research what caused the installation of a given package, I'd like to get a list of packages which depend on that package. I couldn't find anything obvious in man dpkg.

Garrett
  • 730
l0b0
  • 9,271

8 Answers8

523

apt-cache rdepends packagename should do what you want.

To limit it to packages that are installed on your system: apt-cache rdepends --installed packagename

Bram
  • 3,699
RobotHumans
  • 30,112
100

aptitude has a fairly nice way of handling this:

$ aptitude why bash
i   foomatic-filters PreDepends bash (>= 2.05)

By default, it only lists the "most installed, strongest, tightest, shortest" reason, but you can use aptitude -v why to make it output everything it finds.

n.st
  • 1,470
tumbleweed
  • 8,106
51

The simplest option is still:

apt rdepends package-name

which does not require you to install any package.

35
apt-cache showpkg <pkgname> 

Example:

apt-cache showpkg lightdm
Seth
  • 59,332
qorrow
  • 521
21

There is more than one way, with each method showing a different output.

For a detailed view of the full reverse dependency tree;

aptitude install apt-rdepends
apt-rdepends -r bash

Alternatively;

apt-cache showpkg bash

Or a concise list:

apt-cache rdepends bash
Zanna
  • 72,312
papashou
  • 2,460
18

In addition to other good answers, an apt/apt-get -s does a "simulated" removal (or install).

sudo apt -s remove <pkgname>

Using -s or --simulate to remove (or install) packages, will normally list any dependencies affected. It will show orphaned packages when removing, or needed dependencies when installing, without actually executing the install or remove. Informational only.

B. Shea
  • 1,252
3

Since the --installed option of apt-cache was mentioned in comments of RobotHumans's answer and does not make much sense as the matching is done against all versions, including uninstalled ones (see Debian bug 1029586), here's the solution proposed by Julian Andres Klode to get the reverse dependencies among the installed packages:

apt list '?any-version(?installed?depends(?exact-name(packagename)))'

Note that packagename is just the package name, without architecture information. For instance, libpcre3 works, but not libpcre3:amd64.

vinc17
  • 196
2

With the reverse-depends command from the package: ubuntu-dev-tools

reverse-depends libjs-openlayers
# For build depends search
reverse-depends -b libjs-openlayers
Reverse-Recommends
* gis-osm

Reverse-Depends

  • cyclograph
  • phpmyadmin
  • sumo-tools

Packages without architectures listed are reverse-dependencies in: amd64, arm64, armhf, i386, ppc64el, s390x