I don't know of a one-stop command line solution, although all the tools exist (apt-cache depends --installed
, apt-cache rdepends --installed --recurse
, apt-mark showmanual
, dpigs
, etc.). It would be possible to hack together a command line script that could attempt to find large packages with few manually installed reverse dependencies. Here's the proof of concept I used as a starting point:
dpigs | awk 'NR == 1 {print $2}' | xargs apt-cache rdepends --installed --important --recurse | awk '!/:/ {print $1}' | sort -u
On the other hand, if you want to do complex analysis of the graph in multiple directions (e.g., what set of manually installed packages has the largest on-disk overlapping set of recursive dependencies), it can quickly get out of hand. At that point, you'll probably need to look at something more customizable (awk
or python
?).
Full Disclosure: I have contributed to the project below. If that kind of thing matters to you, please take it into account. If I were aware of a similar project that were already in the Debian repositories, I would probably post that instead.
While I prefer to do everything from the command line, you might find pacgraph (also on github) a useful alternative. It was originally written by Kyle Keen for Arch Linux, but it's now compatible with deb- and rpm- based systems as well. I used to have some sample output from an Ubuntu system, but I can't find it, so here's an example from his web site:
.
It's been a while since I've used it, but I believe there are also flags to highlight a particular package, with different colors for its recursive dependencies and reverse dependencies.
APT doesn't know anything about software that was installed manually. It doesn't know what libraries that software needs or anything.
When APT installs a package only to fulfill the dependencies of another package, this package is marked as automatically installed. If you remove all the packages that depend on an automatically-installed package, that package is removed when you run apt-get autoremove
; higher-level frontends to APT will typically offer to do that after other maintenance. To avoid removing packages that are needed by locally-installed software, mark these packages as manually installed: apt-mark manual PACKAGE-NAME
, or the m
key in aptitude.
To find what library packages a binary executable needs, run ldd /path/to/executable
. For each line containing /usr/lib/SOMETHING
, run dpkg -S /usr/lib/SOMETHING
to display the name of the package containing that library. For scripts, head -n 1 /path/to/script
shows the interpreter used by the script; make sure that this interpreter remains installed. Finding what libraries are used by a script can be difficult, there's no universal way to do that.
If you've manually installed a more recent version of a package that's present in your distribution, look at the dependencies of the distribution's package and mark them as manually installed.
Best Answer
With Aptitude, search for the
?obsolete
pattern, possibly with a custom display format.