Product SiteDocumentation Site

6.3. Команда apt-cache

Команда apt-cache может показать много информации из внутренней базы APT. Эта информация представляет собой своего рода кэш, поскольку она собирается из разных источников, перечисленных в sources.list файле. Группировка информации в кэш происходит во время выполнения операции apt update.
Команда apt-cache Команда может выполнять поиск пакетов по ключевым словам с помощью apt-cache search keyword. Она может также отображать заголовки пакетов доступных версий с apt-cache show package. Эта команда предоставляет описание пакета, его зависимости, имена его разработчиков, и так далее. Запомните что apt search, apt show, aptitude search, aptitude show работают одинаковым образом.
Некоторые возможности используется более редко. Для примера, apt-cache dumpavail отображает заголовки всех доступных версий всех пакетов. apt-cache pkgnames отображает список всех пакетов, которые хотя бы один раз появлялись в кеше.
Одной из функций, которая может пригодиться чаще, является apt-cache policy, описанная в следующем разделе.

6.3.1. The apt-cache policy Command

The 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, «Файл /etc/apt/sources.list для пользователей Debian Stable» and APT::Default-Release set to "/^bookworm(|-security|-updates)$/", the output will look like this:
$ apt-cache policy
Package files:
 100 /var/lib/dpkg/status
     release a=now
 990 http://deb.debian.org/debian bookworm-updates/non-free-firmware amd64 Packages
     release v=12-updates,o=Debian,a=stable-updates,n=bookworm-updates,l=Debian,c=non-free-firmware,b=amd64
     origin deb.debian.org
 990 http://deb.debian.org/debian bookworm-updates/main amd64 Packages
     release v=12-updates,o=Debian,a=stable-updates,n=bookworm-updates,l=Debian,c=main,b=amd64
     origin deb.debian.org
 990 http://security.debian.org/debian-security bookworm-security/non-free-firmware amd64 Packages
     release v=12,o=Debian,a=stable-security,n=bookworm-security,l=Debian-Security,c=non-free-firmware,b=amd64
     origin security.debian.org
 990 http://security.debian.org/debian-security bookworm-security/main amd64 Packages
     release v=12,o=Debian,a=stable-security,n=bookworm-security,l=Debian-Security,c=main,b=amd64
     origin security.debian.org
 990 http://deb.debian.org/debian bookworm/non-free-firmware amd64 Packages
     release v=12.5,o=Debian,a=stable,n=bookworm,l=Debian,c=non-free-firmware,b=amd64
     origin deb.debian.org
 990 http://deb.debian.org/debian bookworm/main amd64 Packages
     release v=12.5,o=Debian,a=stable,n=bookworm,l=Debian,c=main,b=amd64
     origin deb.debian.org
Pinned packages:
apt-cache policy также может показать закрепленные приоритеты для всех доступных версий и исходного кода для данного пакета.
$ apt-cache policy adb
adb:
  Installed: 1:29.0.6-28
  Candidate: 1:29.0.6-28
  Version table:
     1:33.0.3-2~bpo12+1 100
        100 http://deb.debian.org/debian bookworm-backports/main amd64 Packages
 *** 1:29.0.6-28 990
        990 http://deb.debian.org/debian bookworm/main amd64 Packages
        100 /var/lib/dpkg/status
Although there is a newer version of adb in the bookworm-backports repository, APT will not install it automatically based on the priority. One would have to use apt install adb/bookworm-backports or add a higher pinning priority to /etc/apt/preferences.d/adb.pref:
Package: adb
Pin: release o=Debian Backports,n=bookworm-backports
Pin-Priority: 1001
$ apt-cache policy limnoria
adb:
  Installed: 1:29.0.6-28
  Candidate: 1:33.0.3-2~bpo12+1
  Version table:
     1:33.0.3-2~bpo12+1 1001
        100 http://deb.debian.org/debian bookworm-backports/main amd64 Packages
 *** 1:29.0.6-28 990
        990 http://deb.debian.org/debian bookworm/main amd64 Packages
        100 /var/lib/dpkg/status