apt-cache
命令可顯示 APT 內部資料庫裡的多種資訊。這些資訊是從 sources.list
檔案內聚集不同來源的快取。於執行 apt update
運作時產生的。
術語 快取
套件名稱
檔案是他們在 Debian 鏡射站的位置。也就是說,近用資料庫套件時,每次都通過網路讀取,極無劾率。所以,APT 在其檔案內儲存一個複本 (在 /var/lib/apt/lists/
) 每次搜尋在地的檔案即可。同樣的,/var/cache/apt/archives/
儲存已經下載的套件避免在移除後又需要時的重複下載行為。
apt update
regularly to update the cache. Otherwise your package search results will always miss the latest updates distributed by the Debian mirrors.
apt-cache
命令可以做鍵詞套件搜尋 apt-cache search 鍵詞
。也能顯示套件標頭的可用版本 apt-cache show 套件名稱
。這個命令提供套件說明、其相依性、維護者名稱等。apt search
、apt show
、aptitude search
、aptitude show
都以同樣方式運作。
其他 axi-cache
apt-cache search
是基礎的工具,應用在 grep
套件描述。輸入過多鍵詞可能送回大量結果或完全無資料。
axi-cache search term
, on the other hand, provides better results, sorted by relevancy. It uses the Xapian search engine and is part of the apt-xapian-index package which indexes all package information (and more, like the .desktop
files from all Debian packages). It knows about tags (see sidebar 進一步 Tag
欄位) and returns results in a matter of milliseconds.
$ axi-cache search package use::searching
100 results found.
Results 1-20:
100% packagesearch - GUI for searching packages and viewing package information
99% apt-utils - package management related utility programs
98% whohas - query multiple distributions' package archives
98% dpkg-awk - Gawk script to parse /var/lib/dpkg/{status,available} and Packages
97% apt-file - search for files within Debian packages (command-line interface)
[..]
90% wajig - unified package management front-end for Debian
More terms: debtags debian paket dpkg search pakete tools
More tags: role::program interface::commandline works-with::software:package suite::debian admin::package-management scope::utility network::client
`axi-cache more' will give more results
apt-cache policy
顯示套件來源及個別套件的優先性。另個例子是apt-cache dumpavail
顯示所有套件全部版本的標頭。apt-cache pkgnames
顯示出現在快取至少一次的套件清單。
秘訣 apt-cache policy
apt-cache policy
command displays the pinning priorities and distribution properties of each package source as explained in 節 6.2.5, “管理套件優先性”. It can also show the pinning priorities for all available versions and sources of a package. For the sources.list
example used in 範例 6.2, “供 Debian 穩定版使用者的 /etc/apt/sources.list
” and APT::Default-Release
set to "buster"
, the output will look like this:
$
apt-cache policy
Package files: 100 /var/lib/dpkg/status release a=now 100 https://deb.debian.org/debian buster-backports/contrib amd64 Packages release o=Debian Backports,a=buster-backports,n=buster-backports,l=Debian Backports,c=contrib,b=amd64 origin deb.debian.org 100 https://deb.debian.org/debian buster-backports/main amd64 Packages release o=Debian Backports,a=buster-backports,n=buster-backports,l=Debian Backports,c=main,b=amd64 origin deb.debian.org 990 https://deb.debian.org/debian buster/non-free amd64 Packages release v=10.0,o=Debian,a=stable,n=buster,l=Debian,c=non-free,b=amd64 origin deb.debian.org 990 https://deb.debian.org/debian buster/contrib amd64 Packages release v=10.0,o=Debian,a=stable,n=buster,l=Debian,c=contrib,b=amd64 origin deb.debian.org 990 https://deb.debian.org/debian buster/main amd64 Packages release v=10.0,o=Debian,a=stable,n=buster,l=Debian,c=main,b=amd64 origin deb.debian.org 990 http://security.debian.org buster/updates/main amd64 Packages release v=10,o=Debian,a=stable,n=buster,l=Debian-Security,c=main,b=amd64 origin security.debian.org
apt-cache policy
can also show the pinning priorities for all available versions and sources of a given package.
$
apt-cache policy iptables
iptables: Installed: 1.8.2-4 Candidate: 1.8.2-4 Version table: 1.8.3-2~bpo10+1 100 100 https://deb.debian.org/debian buster-backports/main amd64 Packages *** 1.8.2-4 990 990 https://deb.debian.org/debian buster/main amd64 Packages 100 /var/lib/dpkg/status
buster-backports
repository, APT will not install it automatically based on the priority. One would have to use apt install iptables/buster-backports
or add a higher pinning priority to /etc/apt/preferences.d/iptables
:
Package: iptables Pin: release o=Debian Backports, a=buster-backports Pin-Priority: 1001