To stay up to date, remember to subscribe to our YouTube channel!
SUBSCRIBE ON YOUTUBE
In Linux we find a large group of commands with which it is possible to perform various support and information tasks, one of these very useful commands is apt-cache, which you will see how to use within this complete tutorial to manage the cache of the system..
The apt-cache command is in charge of doing an analysis and showing the available information about the packages that are installed in the system as well as what can be installed, its work is exclusively based on the data stored in the local cache when the “update” parameter is used.
parameters
Some of the parameters that we can use with apt-cache are:
- showsrc: is in charge of displaying the font information.
- search: its task is to search the list of packages using the regular expression pattern that we indicate.
- depends: Generates available dependency information for the package.
- rdepends – View reverse dependency information for the package.
- show – Displays a readable log for the selected package.
- pkgnames: Creates a list of the names of all the packages on the system.
- policy.: allows us to see the policy parameters of a package.
There are some options to use and TechnoWikis will show you how to access these details..
How to use the apt-cache command in Linux
Step 1
For this case we will use Ubuntu but the process is similar in the other distributions, we open the terminal and we can use the following command to search for all the packages associated with that name:
sudo apt-cache search (name)
Step 2
We go to the bottom to see all the results. There we see that each line is related to the name of the searched package.
Step 3
Now we can use the following command to list the name of all packages without a description:
sudo apt-cache pkgnames
Step 4
Again we go to the bottom to see the other results:
step 5
To see fewer results, or use summary mode, we run the following command:
sudo apt-cache pkgnames | them
step 6
By pressing the Enter key you can see more results. To exit press the q key.
step 7
If desired, it is possible to filter the results for a particular package, in this case use the following command:
sudo apt-cache pkgnames | grep(name)
step 8
There we find all the packages related to that name.
step 9
To access all the details of the package, we will use the following command:
sudo apt-cache show (name)
step 10
There we find details such as:
step 11
If we want to see the dependencies of a package we will execute the following:
sudo apt-cache showpkg(name)
step 12
In order to see the general statistics of the cache we will use the following command:
sudo apt-cache stats
step 13
We see the total number of packages by their type as well as the size of each section. We can see the details of a package installation with the following command. We see if the package is installed or not, its candidate to use, version and more.
So apt-cache is an ally when it comes to working with this type of packages in Linux.