dpkg-query vs apt-cache [duplicate]
I noticed an interesting phenomenon and I am looking for an explanation. On my Ubuntu system, dpkg-query
cannot find some uninstalled packages which apt-cache
can find. For instance,
dpkg-query -l libssl-dev
gives me:
dpkg-query: no packages found matching libssl-dev
while:
apt-cache show libssl-dev
finds the package information. At the same time, dpkg-query
can locate other uninstalled packages, e.g. gimp and show their status as uninstalled. Why are some packages not visible to dpkg-query
?
Basically, dpkg-query
shows you what is installed on your system, or even packages which has been installed on your system and then been removed at some point.
Interestingly enough, if a package uses a dependency of another package, dpkg
may list them as installed even though one of them was never fully installed on the system.
But apt
is used to download packages from the repositories defined in your sources.list and sources.d/* directory.
in other words, apt-cache
shows the packages that "could be installed" on your system not the ones already installed/uninstalled.