Apt-cache - Search for Software Packages

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 search flag.

For example to find out about the package vsftpd, the command would be.

$ apt-cache search vsftpd
apt-cache serach vsftpd package
apt-cache serach vsftpd package

02. To find all the packages starting with a specific string.

For example to list all packages starting with vsftpd, you could use with pkgnames flag.

$ apt-cache pkgnames vsftpd
apt-cache list package starting with vsftpd
apt-cache list package starting with vsftpd

03. To get the exact package name

To get the exact package use apt-cache search with --names-only option.

For example,

$ apt-cache search --names-only vsftpd
apt-cache get only name search from a package
apt-cache get only name search from a package

04. Get the list of all available packages from apt repository.

$ apt-cache pkgnames
apt-cache pkgnames output
apt-cache pkgnames - list all packages

You can make use of grep command to filter specific package from the list.

For example

$ apt-cache pkgnames | grep vsftpd

05. To list all the available packages along with a one-line description of the package.

$ apt-cache search .
apt-cache search - list all package with online description

06. Display header of available specific package

To check package information such as package name, architecture, version, installed size, maintainer, integrity check, description use show flag.

ie. apt-cache show <package name> displayed the package metadata.

For example

$ apt-cache show docker
apt-cache show docker package in detail
apt-cache show package information in detail


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.

Leave a Comment