Can aptitude group or search for packages which nothing depends on

aptitude

With aptitude:

I can see the number of reverse dependencies with %r in the display format string (preferences), but how can I group/limit the package list according to that count?

I want to see/filter/search all packages which nobody depends on.

Best Answer

%r gives you the number of installed packages that depend on that package.

You can list the installed packages for which no installed package depends on with:

aptitude search '~i ! ~R ~i'

You can extend that to recommends and suggests with

aptitude search '~i ! ~R ~i ! ~Rrecommends:~i  ! ~Rsuggests:~i'

You can list packages that no package (installed or not) depend on with:

aptitude search '! ~R .'

If your point is to list packages that you can safely remove, then, as pointed out by Braiam, you may want to also exclude essential packages (~E) and those with required priority (and possibly important).

In aptitude (preferably in flat-list view), press l and enter:

~i ! ~R ~i ! ~Rrecommends:~i  ! ~Rsuggests:~i ! ~E ! ~prequired ! ~pimportant

(once you remove packages, some more packages may pop up in that list once the packages that depended on them have been removed)

See also ~g (?garbage), for the packages which are not installed, or which were automatically installed and are not depended upon by any installed package.

Related Question