How to search for packages in Ubuntu Server with apt cache search

In this tutorial we are going to learn how search packages in Ubuntu using apt-cache search command.

For the same software application, package name can be different depends on the Linux Distribution. For example, Apache Web Server package is called as apache2 in Debian based Distributions, while Red Hat and CentOS refer it as httpd package.

When you are going to install a package in Ubuntu using apt-get install command, you need to know the correct name of the package you want to install. For example, you want to install Java on Ubuntu, But you are not quite sure what is the name of the package that provides Java for Ubuntu Linux.

In Ubuntu Linux apt-get search command helps us to find packages by keywords. So we can know the exact name of the application we want to install.

Search Packages with Apt Cache Search in Ubuntu Linux

To search packages, we use apt-cache search followed by the keyword.

sudo apt-cache search <search keyword>

The output will be the list of packages that match your search criteria and the Package description.

For example, if you want to search for the Apache in Ubuntu,

sudo apt-cache search apache

This will list all packages that related to the Apache. As per the below screenshot, Apache Web Server for Ubuntu provides by the apache2 package.

How to search for packages in Ubuntu Server with apt cache search
apt cache search in Ubuntu 16.014

Then you can install the Apache Web Server with apt-get command.

sudo apt-get install apache2

Match Multiple Search Criteria

By providing multiple keywords, we can search packages that related to both keywords.

In the preceding example, we search PHP packages that related to the Apache Web Server.

sudo apt-cache search php apache

This will give the list of packages that matching for both php and Apache.

Read the Search result with less command

Sometime search result can be very long depends on the number of packages available for the given keyword. If the list is too long, pipe the output to the less command.

sudo apt-cache search php | less

The Linux less command makes it easier to read when the output list is very long.

Examples - Ubuntu apt-cache search

sudo apt-cache search jdk

In the above example, We search jdk which stands for Java Development Kit. Output will be the list of packages related to the JDK on Ubuntu Linux.

ubuntu apt cache search

sudo apt-cache search samba

Search for the packages relates to the samba in Ubuntu Server.

apt-cache search python3

Get the list of available python3 packages in Ubuntu Server.

So that is how we can use apt-cache command to search packages in Ubuntu Linux. This works for All Ubuntu Versions, Including Ubuntu 16.04.