$linuxjunkies
>

apt-cache(8)

Query the APT package cache for package information and dependencies.

UbuntuDebianFedoraArch

Synopsis

apt-cache [OPTION]... COMMAND [PKG]...

Description

apt-cache performs a variety of operations on the APT package cache. It is used to query information about packages, search for packages by name or description, and examine package dependencies and relationships without modifying the system.

Common operations include searching for packages, displaying package details, checking dependencies, and generating statistics about the cache. apt-cache reads from the local cache and does not require root privileges.

Common options

FlagWhat it does
-p, --package-list FILEread package list from FILE instead of the cache
-s, --src-cache FILEuse FILE as the source cache
-q, --quietsuppress normal output (useful in scripts)
-i, --importantprint only important dependencies in depends output
-a, --all-versionsshow all versions of packages
--no-all-versionsshow only the candidate version (default)
-g, --generateperform automatic cache regeneration
--no-generatedisable automatic cache regeneration
-h, --helpdisplay help message

Examples

search for packages matching 'nginx' in cache

apt-cache search nginx

display detailed information about the curl package

apt-cache show curl

show dependencies of the vim package

apt-cache depends vim

show reverse dependencies (packages that depend on libssl1.1)

apt-cache rdepends libssl1.1

display version policy and available versions for python3

apt-cache policy python3

search for exact package name 'gcc' using full-names flag

apt-cache search --full-names '^gcc$'

list all package names containing 'lib'

apt-cache pkgnames | grep lib

display cache statistics including total packages and size

apt-cache stats

Related commands