Skip to content
Latchkey

apt-cache: Search and Inspect Package Metadata

apt-cache queries the local package index for names, versions, and dependencies without touching the system.

When a pinned version fails or a package name is uncertain, apt-cache tells you what the index actually offers. It is read-only and safe in any pipeline.

What it does

apt-cache reads the package index cached by apt-get update. search finds packages by keyword, show prints metadata, policy shows installed and candidate versions, and madison lists every available version across repos.

Common usage

Terminal
apt-cache search postgresql
apt-cache show nginx
# what versions are available (useful before pinning)
apt-cache madison nginx
# installed vs candidate version and priorities
apt-cache policy nginx

Options

SubcommandWhat it does
search <term>Find packages whose name or description matches
show <pkg>Print the package metadata (deps, size, description)
policy <pkg>Show installed version, candidate, and repo priorities
madison <pkg>List all available versions and their source repos
depends <pkg>List the dependencies of a package

In CI

Use apt-cache madison in a debug step to discover the exact version string to pin in apt-get install pkg=version. Run apt-get update first or apt-cache reports stale or empty results.

Common errors in CI

Empty output from apt-cache search or madison usually means apt-get update has not run in this environment. "N: Unable to locate package" style emptiness from madison means the repo providing it is not enabled. apt-cache is read-only, so it will not report lock errors.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →