2

Note: I found this QnA addressing apt-cache show v/s apt-cache showpkg but couldn't find any QnA addressing the difference among all the three options i.e. policy, show, & showpkg.

For example, for a Google Chrome in my Ubuntu 18.04 LTS,
the output of apt-cache policy google-chrome-stable :

google-chrome-stable:
  Installed: 84.0.4147.105-1
  Candidate: 84.0.4147.135-1
  Version table:
     84.0.4147.135-1 500
        500 http://dl.google.com/linux/chrome/deb stable/main amd64 Packages
 *** 84.0.4147.105-1 100
        100 /var/lib/dpkg/status

Output of apt-cache show google-chrome-stable command:

Package: google-chrome-stable
Version: 84.0.4147.135-1
Architecture: amd64
Maintainer: Chrome Linux Team <[email protected]>
Installed-Size: 228519
Pre-Depends: dpkg (>= 1.14.0)
Depends: 
.
.
Recommends: libu2f-udev, libvulkan1
Provides: www-browser
Priority: optional
Section: web
Filename: pool/main/g/google-chrome-stable/google-chrome-stable_84.0.4147.135-1_amd64.deb
Size: 69582256
SHA256: <sha256>
SHA1: <sha1>
MD5sum: <md5sum>
Description: The web browser from Google
 Google Chrome is a browser ... , and easier.
Description-md5: <md5>

Package: google-chrome-stable
Status: install ok installed
Priority: optional
Section: web
Installed-Size: 229295
Maintainer: Chrome Linux Team <[email protected]>
Architecture: amd64
Version: 84.0.4147.105-1
Provides: www-browser
Depends:
.
.
Pre-Depends: dpkg (>= 1.14.0)
Recommends: libu2f-udev, libvulkan1
Description: The web browser from Google
 Google Chrome is a browser ... , and easier.
Description-md5: <md5>

Output of apt-cache showpkg google-chrome-stable command:

Package: google-chrome-stable
Versions: 
84.0.4147.135-1 (/var/lib/apt/lists/dl.google.com_linux_chrome_deb_dists_stable_main_binary-amd64_Packages)
 Description Language: 
                 File: /var/lib/apt/lists/dl.google.com_linux_chrome_deb_dists_stable_main_binary-amd64_Packages
                  MD5: <md5>
 Description Language: 
                 File: /var/lib/dpkg/status
                  MD5: <md5>

84.0.4147.105-1 (/var/lib/dpkg/status)
 Description Language: 
                 File: /var/lib/apt/lists/dl.google.com_linux_chrome_deb_dists_stable_main_binary-amd64_Packages
                  MD5: <md5>
 Description Language: 
                 File: /var/lib/dpkg/status
                  MD5: <md5>


Reverse Depends: 
  goopg,google-chrome-stable
Dependencies: 
.
.
Provides: 
84.0.4147.135-1 - www-browser (= ) 
84.0.4147.105-1 - www-browser (= ) 
Reverse Provides: 

So, apart from the difference among these three, my other queries are:

  1. When should I use which one?

  2. For policy & showpkg options, why it's showing two different versions i.e. 84.0.4147.105-1 & 84.0.4147.135-1? Also, both of them are being printed in proper order. On the other, for the show option, it's gives details about 84.0.4147.135-1 and later on about 84.0.4147.105-1. But, the amount of details as well as order among details is different. Why?

  3. In show and showpkg options, most of the details are twice. Why?

  4. When I checked the version of my Google Chrome using google-chrome-stable --version is showed Google Chrome 84.0.4147.105. So, why I'm getting 84.0.4147.135 as well while running apt-cache along with the above three options?

1 Answer 1

2

The differences are described in man apt-cache. In summary:

  • policy shows priorities, either of all repositories, or of the packages given as arguments;
  • show shows the main package information (all the information in the control files, without relying on any external information);
  • showpkg shows forward and reverse dependencies.
  1. You should use the command which gives the information you’re after. policy for example is useful to determine what versions are available and why they might or might not be installed.

  2. All commands show information about all available versions: the currently-installed version (if any) and the versions in the repositories (as of the last apt update).

  3. The details are repeated because there are two versions available.

  4. The currently-installed version is 105, but 135 is available from the repositories. policy shows 135 as the candidate, so the next upgrade will try to install it.

1
  • Does showpkg show dependencies recursively? Because show also outputs Depends:, but showpkg output is longer and more complex to understand (IMO). E.g. now I see for Dependencies: 1:13.99.1-1ubuntu3.13 -... long line then 1:13.99.1-1ubuntu3.11 - ... and another two similar lines. Why 4 lines with slightly different versions? Dec 28, 2021 at 5:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .