包管理器,dpkg-query 不可用

Joh*_*Sir 5 package-management dpkg

为什么dpkg -p packageName某些包(例如adduserdash)显示其信息,但对于其他包,如 nodejs、git、firefox 显示dpkg-query: package name is not available

Rin*_*ind 7

手册介绍了它;-) man dpkg-query

-p, --print-avail [package-name...]
       Display details about packages, as found in
       /var/lib/dpkg/available.  If no package-name is specified, it will
       display all package entries in the available database (since dpkg
       1.19.1).  When multiple package-name are listed, the requested
       available entries are separated by an empty line, with the same
       order as specified on the argument list.

       Users of APT-based frontends should use `apt show package-name`
       instead as the available file is only kept up-to-date when using
       dselect.
Run Code Online (Sandbox Code Playgroud)

最后一句话解释了它:使用 apt show package-name

例子:

$ apt show firefox
Package: firefox
Version: 87.0+build3-0ubuntu4
Priority: optional
Section: web
Origin: Ubuntu

$ apt show git
Package: git
Version: 1:2.30.2-1ubuntu1
Priority: optional
Section: vcs
Origin: Ubuntu
Run Code Online (Sandbox Code Playgroud)

等等。