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
.
8 Answers
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
-
3
-
3As for today (apt version 0.9.9.1), there is --recurse option that works with rdepends.– jarnoCommented Dec 22, 2013 at 14:00
-
98If you add
--installed
, the output is even useful for packages which can be used by many others:apt-cache rdepends --installed packagename
– quazgarCommented May 27, 2014 at 22:08 -
5There's a slightly different syntax which helped me to differentiate between Recommends, Depends, Suggests, etc. Syntax is
sudo apt rdepends packagename
(Notice it is not using apt-cache but simply apt) Commented Nov 16, 2017 at 5:26 -
7For the output, why do some of the packages have a vertical bar (pipe symbol) before them? Commented Nov 16, 2017 at 5:35
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.
-
7Seems like it considers only the installed packages, not everything available. And that was what I needed. Commented Jul 25, 2013 at 10:06
-
4
-
1
-
1This is great. I learned that
openssh-server
recommended (and therefore installed)xauth
on a headless server, dragging in hundreds of x11 dependencies and dozens of useless updates a month. That's the problem with automated package management!– BaseZenCommented Mar 2, 2018 at 3:17 -
1Worth noting that the
--recurse
option is useful too. As inapt rdepends --recurse packagename
Commented Nov 18, 2020 at 6:22
The simplest option is still:
apt rdepends package-name
which does not require you to install any package.
-
1
-
12The accepted answer has nothing to do with this one. The output is completely different and way more useful for human consumption than apt-cache's. The answer mentions that apt-cache is not installed by default everywhere - that alone should be a rather good hint why this answer has its purpose. finally, this is actually the answer I was looking for, so any downvote is rather silly.– stefanctCommented Nov 28, 2018 at 13:21
-
5One very significant reason why this is better than the accepted version is that it includes the version of the dependencies, unlike
apt-cache
s output. It's exactly what I needed right now (debugging a glibc 2.28 incompatibility, so upvoting) Commented Jan 2, 2019 at 9:10 -
3upvote for using just apt. at the time of the original answer, I'm not sure this just apt solution would have been valid, but if it is now, that's good. Commented Apr 20, 2019 at 11:53
apt-cache showpkg <pkgname>
Example:
apt-cache showpkg lightdm
-
5This is actually still the correct syntax for
apt-cache
. Just triedapt showpkg xorg
and gotE: Invalid operation showpkg
– TerranceCommented Jun 8, 2020 at 14:13 -
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
-
What exactly does
rdepends
show in that tree?apt-rdepends php7.0-fpm
showssed
.sed
doesn't depend on PHP, let alone PHP FPM. Commented Jan 9, 2018 at 23:21 -
It is reverse depends, it means that PHP depends on sed. Commented Apr 25, 2018 at 3:30
-
2Hi guys, actually "apt-rdepends" stands for "recursive dependency". If you want reverse recursive dependency, you have to type :
apt-rdepends -r yourPackageNameHere
– SebMaCommented Apr 27, 2018 at 12:56 -
The apt-cache man page says "rdepends shows a listing of each reverse dependency a package has". Whereas apt-rdepends requires the -r option to do reverse dependencies, as @SebMa says.– NeilGCommented Feb 5, 2019 at 3:16
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.
-
apt remove -s php7.0-fpm
showsThe following additional packages will be installed: apache2 apache2-bin apache2-data libapache2-mod-php7.0 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0
. Why would apache get installed if I remove PHP FPM? Commented Jan 9, 2018 at 23:22 -
@DanDascalescu Hmm. Might be a bad install/remove script for apt pkg or might be you have some other dependencies that install apache2 as dep (meaning a webserver is needed - and I believe apache2 is default web server). Could be a few things. Just not sure. Has the smell of a good post on AskUbuntu if you haven't found an answer.– B. SheaCommented Jul 10, 2018 at 16:26
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
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
.
aptitude
, something that hasn't been installed by default for years. In 2017, everyone on Ubuntu still hasapt-cache
. Anyone who follows the linked question is going to get lost in a discussion about a program few will have.