apt-cache
Search APT package information
TLDR
Search for a package in your current sources
Show information about a package
Show whether a package is installed and up to date
Show dependencies for a package
Show packages that depend on a particular package
SYNOPSIS
apt-cache [options] command
PARAMETERS
search regex...
Searches for packages whose names or descriptions match the given regular expression. This is one of the most frequently used commands to find relevant software.
show pkg...
Displays detailed information about one or more specified packages, including description, dependencies, versions, and file sizes.
policy [pkg...]
Shows the installation policy for packages, indicating which versions are available and which would be chosen for installation based on APT's priorities and pin-settings.
depends pkg...
Lists all direct and indirect dependencies for a specified package, showing a tree-like structure of required packages.
rdepends pkg...
Lists packages that directly or indirectly depend on the specified package (reverse dependencies).
pkgnames [prefix]
Lists all known package names in the system or filters them by a given prefix.
showpkg pkg...
Displays information about a package, similar to 'show' but with a focus on available versions, their dependencies, and reverse dependencies in a more structured format.
dumpavail
Prints a listing of all available packages to standard output, often used for debugging or parsing package metadata.
stats
Displays statistics about the package cache, such as the number of packages, versions, and dependencies.
dotty
Generates a graphviz dot file representing the package dependencies, useful for visualizing complex dependency graphs.
gencaches
Builds APT's package cache from the source lists (normally done automatically by 'apt update').
-q, --quiet
Suppress progress indicators and make output quieter, suitable for scripting.
-s, --no-virtual-packages
Do not display virtual packages in the output.
-n, --no-show-versions
Do not display version information for packages (e.g., with 'pkgnames').
-i, --important
When used with 'depends' or 'rdepends', only show dependencies marked as 'important'.
-f, --full
Show full dependency lists (e.g., with 'depends', showing all versions).
-x, --regex
Treat patterns as regular expressions (default for 'search').
-h, --help
Show a summary of command usage.
-v, --version
Show the program version.
DESCRIPTION
apt-cache is a command-line utility that is part of the APT (Advanced Package Tool) suite on Debian-based Linux distributions. Its primary function is to query, examine, and manipulate the local package cache, which stores metadata about available software packages.
Unlike apt-get or apt, apt-cache does not perform direct package installations or removals. Instead, it provides valuable insights into the package ecosystem, helping users find packages, inspect their dependencies, view available versions, and understand how packages are sourced and managed within the APT system.
It operates on the package metadata stored locally, typically in /var/lib/apt/lists/, which is populated by running apt update. This makes apt-cache an essential tool for system administrators and power users who need to diagnose package issues, explore software options, or understand the complex relationships between different software components.
CAVEATS
All information provided by apt-cache is derived from the local package cache. This cache must be kept up-to-date by regularly running apt update to ensure accuracy. If the cache is stale, apt-cache might report outdated package versions or availability status. Also, while powerful for querying, apt-cache does not directly modify the system; it only provides information.
LOCAL CACHE LOCATION
apt-cache operates on data stored primarily in the /var/lib/apt/lists/ directory. These files are package metadata downloaded from the repositories defined in /etc/apt/sources.list and /etc/apt/sources.list.d/.
MODERN USAGE VS. APT
For common tasks like searching or showing package details, the newer apt command is often preferred due to its more user-friendly output and consolidated interface (e.g., apt search vs. apt-cache search). However, apt-cache retains unique and powerful commands like policy, depends, rdepends, and stats that are not fully replicated in apt, making it indispensable for advanced package analysis and system administration.
HISTORY
APT (Advanced Package Tool) and its associated utilities, including apt-cache, were developed by the Debian project to provide a robust and flexible package management system. apt-cache has been a core component of APT since its early days, designed specifically for querying the rich metadata stored in the package cache. While the newer, more user-friendly apt command (introduced around 2014) has absorbed some of apt-cache's functionalities (like apt search and apt show), apt-cache remains crucial for more specialized queries, detailed dependency analysis, and scripting purposes, offering granular control and specific output formats not always available in the consolidated apt command.