[one-liners] Find Reverse Depends of a Package

Sometimes you have a package installed and you want to know what other packages depend on it (such as a lib package). This one-liner only works on Debian/Ubuntu (apt/dpkg) based systems, but I’m sure a simmilar method works for rpm based distros such as CentOS.

for depends in $( apt-cache rdepends ${package} ); do dpkg -l | grep ${depends}; done

Where ${package} is the name of the package you are looking to find which other packages are dependent on it. Lets see it in action:

OK so what happened here…

apt-cache rdepends ${package} provides us with a list of packages which depend on the package – which for most cases that would be the end of it. But I like pretty things… So we place that list into a loop, for each package in the list, we run dpkg -l which lists all packages, pipe that into grep ${depends} to list (and colorize*) the results in a nice ordered list.

I could have done this without grep and run dpkg -l ${depends} but then we would get some unnecessary output. This method also makes it easy for scripts looking for the reverse-depends of a given package, and what the install status, versions and architectures are.

* Note: I have a grep alias which includes –color
Tagged with: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.