For each package I have installed I would like to know which packages would be installed if I uninstall it. An example of the output I need is (package: list of deps
):
abc: foo bar
bcd: baz abc
bdd: baz fuubar
Append
If I check what really would be removed if I remove the package ppp
using apt-get
:
$ echo $(apt-get --dry-run remove ppp | grep '^Remv ' | cut -d' ' -f2)
gnome-ppp mint-meta-xfce network-manager-pptp-gnome network-manager-pptp wvdial pppoeconf pppoe pptp-linux pppconfig ppp
I see that it is different from what apt-cache
show gives me (which I do not think include recursive dependencies):
$ apt-cache show ppp | grep '^Breaks: '
Breaks: network-manager (<= 0.8.0.999-1), network-manager-pptp (<= 0.8.0.999-1), pppdcapiplugin (<= 1:3.9.20060704+dfsg.1-1)
Append 2
Is dpkg --get-selections | cut -f1
a reliable way to get a list of installed packages to iterate over?
Best Answer
You asked a few different question here, I hope I can at least help on one or two.
To list all installed packages, use
dpkg
to output in a field separated listTo just get the package list, without extra fields, so you can pipe it elsewhere.
For example, if I want to remove an old kernel,
The easiest way to go through all unneeded dependencies, is with
debfoster
. It runs interactively and goes through what you want, their dependencies and can remove or list what is not a recursive dependency.To list all recursive dependencies of a specific package,
After you have executed
debfoster
you can check any dependents a package has also,A really great way to list 'orphaned' packages, is with
deborphan
. Rundeborphan
without options, and it will list all 'orphaned' packages. An 'orphan' is a package that nothing depends on, and you have not explicitly installed.I also like to clean any 'orphaned' packages, after a fresh install. After I have removed specific packages, you can get anything missed by
apt-get autoremove --purge
with,Finally sometimes you don't
--purge
and end up with package 'leftovers', the newer versions ofapt-get
can automatically remove them. To remove all 'leftovers' from uninstalled packages run,If you don't have the new version of
apt-get
, you can always remove them with these commands. They error if no 'leftover' files exist, it seems like autoclean can miss some occasionally regardless.