Packages and backups
The apt-cache command
Queries the package index of the configured repositories: searches, dependencies and available versions. It installs and changes nothing. It is how apt tells you what exists before you install anything.
Most useful options
search <texto>Searches packages by name or description. It is the command for finding something new.show <paquete>Shows the record: version, size, dependencies and description.policy <paquete>Installed and candidate versions, and which repository each comes from.depends <paquete>Direct dependencies of the package.rdepends <paquete>Packages that depend on this one: useful before removing something.madison <paquete>Available versions, one per line and repository.pkgnames [prefijo]Lists package names that start with that prefix.statsCounts the package names and versions in the local index.Copy-ready examples
$ apt-cache search nginxPackages whose name or description contains nginx.Example output
nginx - small, powerful, scalable web/proxy server nginx-common - small, powerful, scalable web/proxy server - common files
$ apt-cache policy curlInstalled version, candidate version and the repository of each.Example output
curl:
Installed: 8.5.0-2ubuntu10.4
Candidate: 8.5.0-2ubuntu10.4
Version table:
*** 8.5.0-2ubuntu10.4 500
500 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages$ apt-cache depends gitWhat git needs to run, package by package.$ apt-cache madison curlEvery version of curl that each repository offers.$ apt-cache statsHow many packages the local index knows about.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| E: No packages found | No package with that name exists in the active repositories, or the name is misspelled. | Search with apt-cache search word and, if it does not appear, run sudo apt update. |
| No error message | The index is outdated: new packages do not appear until you run apt update. | Refresh the list with sudo apt update and search again. |
| bash: apt-cache: command not found | The system is not Debian or a derivative: apt-cache does not exist on Fedora, Arch or macOS. | Use your distribution's package manager: dnf search, pacman -Ss or brew search. |
Typical mistakes
- apt-cache uses the last downloaded list: if you search for something just published, update first.
Differences from similar commands
Security
Every repository listed by policy is a source of software you trust when you install. Review /etc/apt/sources.list and sources.list.d and remove the ones you do not recognize: a poorly maintained third-party repository can serve altered versions.
FAQ
How do I find a package when I do not know its name?
Search by keyword with apt-cache search. apt-file search header.h finds the package that ships a file, if you have apt-file installed.
Why does policy say 'Installed: (none)'?
The package is not installed. Candidate shows the version that apt install would install.
What changes compared with apt search?
apt is meant for the terminal and its output may change; apt-cache is more stable for scripts.
More Packages and backups commands
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course