Why are some packages found by dpkg-query as with unknown desired action and with not-installed status while other packages are not found at all? For example I have never installed package named debian-handbook, but it somehow shows up in output of dpkg-query -l debian-handbook or dpkg-query -s debian-handbook. On the other hand, for example some packages, which I have also never touched, do not show up in output of dpkg -l:root@T60:~# dpkg -l gkermitdpkg-query: no packages found matching gkermitroot@T60:~# apt-cache policy gkermitgkermit:  Installed: (none)  Candidate: 1.0-9  Version table:     1.0-9 0        500 http://http.debian.net/debian/ jessie/main i386 Packagesroot@T60:~# 
How are some deb packages found by dpkg-query while they have never been installed?
debian;dpkg
I think dpkg -l finds packages that are mentioned as dependencies of packages that are currently installed, and doesn't find other available packages. (Here installed includes conffiles-only packages, i.e. packages that have been removed but not purged, listed as uc in dpkg -l.) dpkg -l lists packages that are mentioned in the dpkg status file (/var/lib/dpkg/status).There may be other reasons that determine whether a package is listed by dpkg -l, but I think this is the main one.