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:
Replace the word characters with the actual characters of the package. For instance, let’s search for package names with “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:
In case you want to know what dependencies a package depends upon, use the “depend” option with the 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.
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.
To search within the installed packages, you can use the “—installed” option.
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.