Apt-cache is a command-line tool that queries and displays available information about packages from local APT files. Package information includes the package name, description, version, dependencies, repo, and maintainer.
The local apt files which store the copy from Debian mirror is in /var/lib/apt/lists/. This file is updated each time apt update command executed. This way when someone searches for packages system doesn't have to go through the different networks to fetch Debian mirrors.
Information source depend on the repo listed in the /etc/apt/sources.list file and third party repo stored in /etc/apt/sources.list.d directory.
Apt-cache is commonly used for searching packages. In this tutorial, we learn how to use apt-cache command to search packages.
Apt-cache search package
01. Keyword based package search
To search for a package using a keyword use
For example to find out about the package
vsftpd, the command would be.
$ apt-cache search vsftpd
02. To find all the packages starting with a specific string.
For example to list all packages starting with
vsftpd, you could use with
$ apt-cache pkgnames vsftpd
03. To get the exact package name
To get the exact package use apt-cache search with
$ apt-cache search --names-only vsftpd
04. Get the list of all available packages from apt repository.
$ apt-cache pkgnames
You can make use of grep command to filter specific package from the list.
$ apt-cache pkgnames | grep vsftpd
05. To list all the available packages along with a one-line description of the package.
$ apt-cache search .
06. Display header of available specific package
To check package information such as package name, architecture, version, installed size, maintainer, integrity check, description use
ie. apt-cache show <package name> displayed the package metadata.
$ apt-cache show docker
Apt search, apt show, aptitude search, aptitude show does the similar thing but output text format may vary.
Apt-cache comes with basic installation in Debian/Ubuntu family. I hope this tutorial helped you to search for the packages in Debian/Ubuntu Distributions.