Dpkg

dpkg –status package_name

  • December 20, 2014

我只是在玩 Ubuntu 14.04.1 LTS。我安裝了 emacs,並想仔細檢查它是否是。

~ 1496 $ dpkg --status emacs
dpkg-query: package 'emacs' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.

~ 1497 $ apt-cache show emacs

Package: emacs
Priority: optional
Section: editors
Installed-Size: 25
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Rob Browning <rlb@defaultvalue.org>
Architecture: all
Source: emacs-defaults
Version: 45.0ubuntu1
Depends: emacs24 | emacs24-lucid | emacs24-nox
Filename: pool/main/e/emacs-defaults/emacs_45.0ubuntu1_all.deb
Size: 1624
MD5sum: 2648ac76d7058d4a722ae304e474aa06
SHA1: 6667aaf3b043b44f10271b943dbb9dbb9620dbf2
SHA256: cb9185c543841971a754ebf8c6a35396c865171532b407dce5b5447c41cfa232
Description-en: GNU Emacs editor (metapackage)
GNU Emacs is the extensible self-documenting text editor.
This is a metapackage that will always depend on the latest
recommended Emacs release.
Description-md5: 21fb7da111336097a2378959f6d6e6a8
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 5y

現在它似乎已安裝,但我仍然很困惑為什麼第一個命令顯示“未安裝 emacs ….”。

我懷疑你已經安裝了emacs24包而不是emacs元包。檢查:

dpkg --status emacs24

此命令的輸出也可能會有所啟發:

dpkg -l | grep '^ii.*emacs'

你寫了:

現在好像安裝好了

emacs您是否通過查看 的輸出來斷定該軟體包已安裝apt-cache show?如果是這樣,那是不正確的。apt-cache show將為任何安裝或未安裝的軟體包提供類似的輸出。特別是,

Installed-Size: ...
[...]
Size: 1624

無論是否安裝了軟體包,都會顯示。

引用自:https://unix.stackexchange.com/questions/175139