Debian Packages – How to List Packages with No Manually Installed Dependencies

aptdebiandependenciesdpkgraspbian

First, to clarify the terminology:
dependency <-> reverse dependency/dependent

I have xvt installed on my headless RPI, and I can't figure out the reason why it's not getting autoremoved.

$ sudo apt autoremove
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ apt show xvt                                                         Package: xvt                                                                       Version: 2.1-20.3
Priority: optional
Section: x11
Maintainer: Sam Hocevar (Debian packages) <[email protected]>
Installed-Size: 85.0 kB
Provides: x-terminal-emulator
Depends: libc6 (>= 2.4), libx11-6
Suggests: menu
Conflicts: suidmanager (<< 0.50)
Download-Size: 36.3 kB
APT-Manual-Installed: no
APT-Sources: http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages
Description: ...
$ apt-cache rdepends --installed xvt
xvt
Reverse Depends:

These don't list xvt

$ dpkg-query -Wf '${Package;-40}${Essential}\n' | grep yes
$ dpkg-query -Wf '${Package;-40}${Priority}\n' | grep -E "important"
$ dpkg-query -Wf '${Package;-40}${Priority}\n' | grep -E "required"
$ apt-config dump | grep '^APT::NeverAutoRemove::'
$ apt-mark showmanual
bullseye-default
equivs
pihole-deps
smbclient
transmission-daemon
wireguard-tools
$ apt-mark showhold

(I don't love debian's way of using lists and fields besides explicit dependencies, I find it obscure. Hence why I created a bullseye-default metapackage.)

What other mechanism could keep this package from being removed?

Getting back to the question posed, how would I find other secretly redundant packages like xvt in this example?

Requested commands

$ dpkg -l xvt
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=====================================>
ii  xvt            2.1-20.3     armhf        X terminal-emulator similar to xterm,

Best Answer

Your apt-cache rdepends output suggests that nothing is keeping your xvt package installed, which is odd given your autoremove behaviour.

In general, to figure out why a given package is being kept, the best tool is aptitude why:

aptitude why xvt

(you may need to install aptitude first).

To list all the packages that don’t have a manually-installed package in their reverse dependencies, run apt autoremove in simulation mode, ignoring recommended and suggested packages:

sudo apt autoremove -s -o Apt::AutoRemove::SuggestsImportant=0 -o Apt::AutoRemove::RecommendsImportant=0

Note that by default, autoremove is imbalanced: recommended packages are installed by default, not suggested packages; but suggestions prevent autoremoval. See How do recommends and suggests interact with apt-get dist-upgrade and apt-get autoremove? for details.

Related Question