1

After reading this question, I'm still confused about two other commands, namely apt-cache pkgnames and dpkg --list. apt-cache pkgnames doesn't return the same list as apt list, a command mentioned in the other question. Could you tell me what the difference between the three is?

2

1 Answer 1

2

apt-cache pkgnames is designed for use in tab-completion: it quickly generates a list of all the package names apt knows about for the system’s main architecture (whether installed, available remotely, or simply mentioned in some other package’s relationships). It’s not intended for direct human consumption, and doesn’t spend much time filtering, so it lists packages other commands won’t necessarily show (such as virtual packages).

dpkg --list lists all the packages dpkg knows about, along with their status, description, and version; dpkg doesn’t know about remote packages, so this mostly lists packages which are installed or removed (but not purged).

apt list lists all the packages apt knows about, along with the repositories they’re available in, whether they’re installed, the available versions, and whether they’re upgradable. It shares the same basic list of packages as apt-cache pkgnames, but it includes any configured architecture; for example on typical multiarch amd64/i386 setups, apt-cache pkgnames won’t list i386-only packages, but apt list will.

dpkg --list and apt list support various options and filters to limit what they display.

4
  • Could you further clarify what the difference is between apt-cache pkgnames and apt-list. You say that both commands list all the packages that apt knows about. What is the difference between the two then? Does apt list also know about remote packages for example?
    – Thomas
    Mar 31, 2020 at 18:13
  • See my update. The differences are in the information included in the output, and that apt list includes packages for other architectures (if any). Mar 31, 2020 at 21:18
  • Thank you. Will apt list --installed also include in its list all the packages which can be found with dpkg-query -l? I mean, does apt list also look into the dpkg database? And does apt also use a database or does it instead look into specific directories to know what is available and installed?
    – Thomas
    Apr 1, 2020 at 13:33
  • apt has its own database (the package lists retrieved from repositories), but it also looks at the dpkg database. Apr 1, 2020 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.