Let’s Play With ‘apt-cache’ Some More!

People use apt, and apt-get, all the time. We use it for the most basic things. We use apt to install, remove, and purge software. However, there’s apt-cache and it’s pretty handy.

A couple of days ago, I published an article about using apt-cache to find the official project homepages of your installed software. Today, I’m going to quickly cover some of the other things you can do with apt-cache. Obviously, if you don’t have apt and apt-cache then this article will do you exactly no good.

So, where to begin? Let’s just assume you’ve already installed inxi and you know how to open the terminal by pressing CTRL + ALT + T on your keyboard.

Done? Good, let’s get started!

First, if you want to display a bunch of generic information, you can use the following:

[code]apt-cache show inxi[/code]

That will show you a bunch of information about a package. You don’t even have to have it installed. For this one, you will have to have the complete package name for it to be successful. In the next command, that’s not really required.

[code]apt-cache search inxi[/code]

For example, you could type in ‘inx’ and it will find inxi, among other things. You can use that command with the ‘–full’ switch, and get a ton of information, like so:

[code]apt-cache search –full inxi[/code]

Anyhow, you don’t even have to use an application name with the search. You can search for keywords and find applications that way. If you wanted to see what text editors you might have available (you’ll need to weed through them carefully) then you’d use this command:

[code]apt-cache search text editor[/code]

Go ahead and give it a try. You might be surprised at the vast number of results you’ll get with that command. Seriously, it’s a lot of results. There’s probably some text editors you’ve never heard of before hidden among those results!

Next on the list is checking the policy. This way you can see what version is installed, what version is available, and you can even see what repository was the source for the application. It’s just as easy as the rest.

[code]apt-cache policy inxi[/code]

Among this giant, perhaps overwhelming, source of data are a couple of other neat things you can do. You can easily see both the dependencies and the reverse dependencies.

For clarity sake, the dependencies are the extra software that needs to be installed for the package in question to function. The reverse dependencies are what packages require the installation of the package in question in order to be fully functional.

To find the dependencies:

[code]apt-cache depends inxi[/code]

And the reverse dependencies:

[code]apt-cache rdepends inxi[/code]

And, there you have it. Those are the most common ways you’re going to use apt-cache. There are other ways and there is more information available, but those are pretty much all the ways you can expect to use it in the normal course of activities. If you want to know more, you can always check the man page. To do that, it’s just:

[code]man apt-cache[/code]

And, there’s one bonus round! There’s pretty much no good reason to run this, other than curiosity, but you can actually get some pretty cool stats about how many packages are available, how many are real packages, how many are virtual packages, and things like that. It’s a pretty simple command.

[code]apt-cache stats[/code]

See? Another lovely way to use the terminal to gather information. I use the terminal nearly exclusively to manage my installed software.