Software

Let’s Play Around With ‘apt-cache’

Today, we’re going to learn about apt-cache. Obviously, this information is only useful for distros that use the apt package manager. You’ll find that apt, and apt-cache, are package management tools – useful for managing (installing, removing, and updating) the software on your computer.

To know about apt-cache, we should probably know about apt. I think the man page describes apt well enough with this:

apt provides a high-level commandline interface for the package management system.

And apt-cache defines itself as:

apt-cache – query the APT cache

While it further describes it as:

apt-cache performs a variety of operations on APT’s package cache.

As you can see, they’re necessary and valuable tools for the management of software on your Linux box. Not all distros use apt, but it’s generally used by the distros in the Debian family. Those are distros like Ubuntu, the official Ubuntu flavors like Lubuntu, Kubuntu, and Ubuntu Mate, as well as distros like Linux Mint. 

So, it’s used by quite a few distros and, importantly, many of those distros are the favorites for people who use Linux on the desktop. I’ll also note that apt works equally fine in a server environment, without a desktop. It’s widely used, widely supported, and easy to find assistance when you have questions.

Today, we’ll just be covering ‘apt-cache’ and some of the basic usage. It’s not a very deep article, nor does it need to be. While there are a ton of apt-cache options, chances are that you’ll only need to use a few of them. So, this shouldn’t take too long out of your day, or will make a good resource when you need to remember something.

Using apt-cache:

This article requires an open terminal. Just press CTRL + ALT + T and your default terminal should open.

For this article, our example will be inxi. We’ll assume you’ve already installed it, or are already familiar with it. If you don’t have it installed, now would be a good time to do so – as it’s a very handy tool. Where you see ‘inxi’ you can use any other package name you want. 

An easy command, if you want to display a bunch of generic information about a package, is the following:

apt-cache show inxi

That will show you a bunch of information about a package, installed or not. It requires the complete package name. In the next command, that’s not really required.

apt-cache search inxi

With the search flag, 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 useful information:

apt-cache search --full inxi

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 a text editor, you can use:

apt-cache search text editor

You might be surprised at the number of results you’ll get with that command. There’s probably some text editors you’ve never heard of before, and they’re right there among those results! Installing them is just a command away!

We can also check the policy, showing things such as which version is installed, which version is available, and the repository name. It’s just as easy as the rest.

apt-cache policy inxi

The output of that command is pretty handy. It’s a short output that tells you which version you have and which version you have installed. It’ll also tell you which repositories hold the software, often more than one, and what the priorities are for those repos.

Bonus apt-cache Features:

Among these great features, you can easily see both the dependencies and the reverse dependencies. Dependencies are the extra software that needs to be installed for the package in question to function and reverse dependencies are those packages that require the installation of the named package to be fully functional.

To find the dependencies:

apt-cache depends inxi

The reverse dependencies:

apt-cache rdepends inxi

There you have it! Those are the most common ways you’re going to use apt-cache. If you want to know more, you can always check the man page with man apt-cache. Dependencies, both regular and reverse, are probably worthy of their own article at some point. Normally, your package manager will deal with those, but you sometimes come across situations where you need to resolve dependencies on your own.

Closure:

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 with a lot of output.

apt-cache stats

See? Another lovely way to use the terminal to gather information. Personally, I do pretty much all my software management in the terminal. I just find it easier, more informative, and faster. I’ve done it for so long that it’s legitimately faster for me to use the terminal than it is for me to do so in the GUI.

Anyhow, thanks for reading. This is yet another article in a growing list of articles! We’re well past the halfway point in the year-long project and so far we’ve yet to miss a single publication date!

It’s going to feel good to finally say that my obligations are over – and then to probably keep writing just to keep getting more and more of this stuff online on my own site. ‘Cause that’s the kind of thing I do… In theory, I’m retired. However, I keep obligating myself to do more and more things. Ah well… This site is at least productive and, judging by the numbers, beneficial to the community.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Recent Posts

Enable/Disable Your Network Interface

Today we'll cover one way to enable or disable your network interface in the Linux…

7 months ago

Check Your NIC Speed In The Terminal

Today's exercise is a nice and simple exercise where we check your NIC speed in…

7 months ago

Easily Monitor Your Wireless Connection

Have you ever wanted to easily monitor your wireless connection? Well, now you can learn…

7 months ago

Count The Files In A Directory

I think I've covered this before with the ls command but this time we'll count…

7 months ago

Get System Information With The ‘uname’ Command In Linux

Today we'll be learning about a basic Linux command that's known as 'uname' and it…

7 months ago

hardinfo Has Been Rebooted As hardinfo2

If you've used hardinfo in the past, it may interest you to know that hardinfo…

7 months ago