How to Use Apt-Cache to Search for Package Information in Linux

APT stands for Advanced Package Tool which is commonly used to install the packages in Linux and Unix-like systems. It maintains the package cache that stores the information about all the available packages, and users can access it using apt-cache. It is a potent command that you can use to retrieve a full-fledged description of any package.

This further helps you know what packages are available to install, the description of specific packages, the dependencies of a package, etc. Many users don’t know that you can use the “apt-cache” command to check the package information. So, in this tutorial, we will briefly explain how to use apt-cache to search for package information in Linux.

How to Use Apt-Cache to Search for Package Information in Linux

The apt-cache is a versatile command that comprises of several options for different results. You can use apt-cache to streamline the package management tasks and become more efficient at installing and updating the packages in Linux.

1. Verify the Installation of Apt-Cache

Although apt-cache comes preinstalled in most Linux systems, you must verify that your system has it:

How to Search for Packages Using Apt-Cache

Searching for packages is one of the core functionalities of apt-cache which is an effortless task. To search for a package, open the terminal, and type and enter the following command:

1. Use Apt-Cache to Get an Information of Installed Packages
If you want to know which packages you installed in your Linux system, apt-cache has a subcommand for this task. You can use this syntax for the same purpose:

2. Use Apt-Cache to Get an Information of Available Packages
You can use the “show” option to get a detailed result about a specific package. For example, you have a package name and you want to know its description, installation size, latest version, installed version, maintainer, and more. In this case, use the “show” query as follows:

Again, replace the term “package” with the package name that you are searching. We used it to know about the “curl” package.

3. Use Apt-Cache for Advance Searches
Sometimes, you can’t recall the exact name of the package, so you can use the “apt-cache names only” search. The query allows you to match the specified characters with available package names:

apt-cache search –names-only  ‘characters’

Replace the word characters with the actual characters of the package. For instance, let’s search for package names with “jQuery”.

apt-cache search –names-only ‘jquery’

This command gets you a list of packages that consist of “jQuery” anywhere in their name.

If you remember a word or a phrase from the description of a package rather than its name, use the description keyword in the search. For example, for a package having the word “graphics” in its description, you can use the following syntax:

apt-cache search “graphics”

In case you want to know what dependencies a package depends upon, use the “depend” option with the package name.

apt-cache depends package_name

For example, let’s replace the “package_name” with curl to get its details.

Similarly, you can use “rdepends” (reverse dependencies) to know which packages depend on a specific package.

apt-cache rdepends packagename

You can use the “-q” or “—quiet” option to limit the search result to package names. It comes in handy to create a list of packages.

apt-cache -q search packagename / apt-cache –quiet search packagename

To search within the installed packages, you can use the “—installed” option.

Apt-cache –installed search packagename

Conclusion

Apt-cache is a versatile command and allows you to perform many operations that facilitate the package search. In this tutorial, we explained how you can use apt-cache to search for online packages and the methods to retrieve an information regarding the installed packages. Furthermore, it is essential to know about these commands to manage the packages in Linux effectively.

source

Leave a Comment