Debian

How to use apt-cache search to find packages

How to use apt-cache search to find packages
Ever faced a problem while installation for apt package, when you do not know the exact package name. As with apt, you have to provide the full name of the package in order to install it such as apt install apache2. If you do not provide the exact name and just type apache, it will not be going to install. The same goes true while removing an apt package.

In Ubuntu and Debian systems, you can search for any package just by a keyword related to its name or description through the apt-cache search. The output returns you with a list of packages matching your searched keyword. Once you find the exact package name, you can then use it with the apt install for installation. It's also helpful when looking for information about a specific package. Note that with apt-cache search, you can search for any apt package that is installed or yet to be installed.

This article will explain you how to search for a package through the apt-cache search command in your system repositories. We will also learn some other commands: apt search and aptitude through which you can also search for any package.

Note: We have performed the procedure explained in this article on the Ubuntu 18.04 LTS system Terminal. To open the Terminal in Ubuntu, use the Ctrl+Alt+T keyboard shortcut.

Before performing any of the following methods, we will recommend you to update the repository index as follows:

$ sudo apt update

Search Packages using apt-cache search

Apt-cache is a command-line tool used for searching apt packages on a Ubuntu or Debian based systems. With apt-cache search, you can search for any package using the keyword related to its name or description. In the output, it displays all the packages matching the search criteria.

With apt-cache search, you can search and display the information about the available packages from the internet repositories. It can also be used to search for information about the packages which are already installed on your system. It obtains information about the packages from different sources and saves them in the local database which is updated by running the apt update operation.

In order to search for packages, type apt-cache search followed bt the relevant keyword. Here is the syntax to do so:

$ sudo apt-cache search

Replace the keyword with any of installed or installable package name. Note that the keyword can be exact or a part of the package name or it can be any word related to package description. In the output, you will see a list of packages matched with the mentioned keyword and a brief description of each package.

For instance, we want to install a storage management solution ZFS. To find the exact package name, let's search it using apt-cache search as follows:

$ apt-cache search zfs

From the output, you can identify the exact package name that is “zfsutils-linux” along with a short description. As you can see the list it displayed is too long. You can use the less command to view output one line or one screen at a time.

$ sudo apt-cache search zfs | less

Similarly, the apt-cache search can be helpful if you want to install a web server but do not remember the name of the package. In this case, you can search for the package using any keyword related to the package description. For instance, I found it really helpful once I needed to install the search engine about which I only know that it's a meta search engine that protects the privacy of its users. However, i did not remember the name of that search engine, so i have entered the search term as follows:

$ sudo apt-cache search “metasearch engine”

When the result appeared, I found the required search engine name that was “Searx”. After that, I simply used the apt install searx command to install it.

Similarly, if we use apt-cache with show flag, it will display basic information about the package including the version, size, dependencies, description and much more. To find information about a certain package, use the show flag as follows:

$ apt-cache show

Alternative ways

Here are some other ways which can also be used to search for an installed or installable package in a system.

Search Packages using apt Search

Apt search is the apt equivalent of apt-cache search in older apt-get command. Some users prefer the apt search command because of its well presented display of results. It displays the packages list along with their latest available versions and a short description. The best thing about apt search is that it highlights the packages name and maintains some space among different packages. Also, you will see the Installed label at the end of the already installed packages.

In order to search for a package, type apt search followed by the keyword related to the package name.

$ apt search keyword

An example of this would be searching for the Apache2 package using the following command:

$ apt search apache2

Search Packages using aptitude

Aptitude is the front end of the apt command in Linux used for installing, upgrading, and removing packages. It can also be used for searching a package in a Linux system.

Aptitude is not installed by default in Linux, so you will have to manually install it. To do so, execute the install command as follows:

$ sudo apt install aptitude

The system might ask for confirmation by providing you with a Y/n option. Hit y and then Enter to confirm, after that the Aptitude will be installed on your system.

Now, in order to search for a package through aptitude, type apt search followed by the keyword related to the package name.

$ aptitude search

You will see the results similar to the following:

That is all there is to it! In this article, we have learned how to search for a package using the apt-cache search command. In addition, we also learned the use of apt search and the aptitude command to search for a package. I hope it will be helpful whenever you need to search for either an installed or installable package in your system.

Cele mai bune jocuri pentru a juca cu urmărirea manuală
Oculus Quest a introdus recent marea idee de urmărire manuală fără controlere. Cu un număr din ce în ce mai mare de jocuri și activități care execută ...
Cum se afișează suprapunerea OSD în aplicații și jocuri Linux pe ecran complet
Jucarea jocurilor pe ecran complet sau utilizarea aplicațiilor în modul ecran complet fără distragere vă poate elimina din informațiile relevante ale ...
Top 5 cărți de captură a jocului
Cu toții am văzut și ne-au plăcut jocurile de streaming pe YouTube. PewDiePie, Jakesepticye și Markiplier sunt doar câțiva dintre cei mai buni jucător...