How to Use apt-cache Command in Linux

How to Use apt-cache Command in Linux


With apt-cache command, you possibly can seek for bundle particulars within the native APT cache. Study to make use of apt-cache command on this tutorial.

What’s apt-cache command used for?

The apt bundle supervisor works on an area cache of bundle metadata. The metadata normally consists info like bundle title, model, description, dependencies, its repository and builders. With the apt-cache command, you possibly can question this native APT cache and get related info.

You possibly can seek for the provision of a bundle, its model quantity, its dependencies amongst different issues. I’ll present you easy methods to use the apt-cache command with examples.

The placement of APT cache is /var/lib/apt/lists/ listing. Which repository metadata to cache will depend on the repositories added in your supply checklist within the /and many others/apt/sources.checklist file and extra repository recordsdata situated in ls /and many others/apt/sources.checklist.d listing.

For sure, the APT packaging system is used on Debian and Debian-based Linux distributions like Ubuntu, Linux Mint, elementary OS and many others. You can not apply it to Arch or Fedora.

Utilizing apt-cache command

How to Use apt-cache Command in Linux

Like another Linux command, there are a number of choices out there with apt-cache and you may all the time consult with its man web page to examine them.

Nevertheless, you most likely gained’t want to make use of all of them. For this reason I’m going to point out you solely the commonest and helpful examples of the apt-cache command on this tutorial.

It’s all the time a good suggestion to replace the native APT cache to sync it with the distant repositories. How do you do this? You employ the command:

sudo apt replace

Seek for packages

The commonest use of apt-cache command is for locating bundle. You need to use a regex sample to seek for a bundle within the native APT cache.

apt-cache search package_name

By default, it appears to be like for the search time period in each the title and outline of the bundle. It reveals the matching bundle together with its quick description in alphabetical order.

How to Use apt-cache Command in Linux

You possibly can slim down your search to search for the search time period in bundle names solely.

apt-cache search –names-only package_name

How to Use apt-cache Command in Linux

If you need full particulars of all of the matched packages, chances are you’ll use the –full flag. It can be used with –names-only flag.

How to Use apt-cache Command in Linux

Get detailed bundle info

If you realize the precise bundle title (or when you’ve got manged to search out it with the search), you may get the detailed metadata info on the bundle.

apt-cache present package_name

How to Use apt-cache Command in Linux

You possibly can see all form of particulars within the bundle metadata like title, model, developer, maintainer, repository, quick and lengthy description, bundle measurement and even checksum.

There’s another choice showpkg that shows details about the bundle title, model and its ahead and reverse dependencies.

apt-cache showpkg package_name

apt-cache coverage

This is among the not often used possibility of apt-cache command. The coverage choices helps you debug the difficulty associated to the desire file.

Should you specify the bundle title, it can present whether or not the bundle is put in, which model is offered from which repository and its precedence.

How to Use apt-cache Command in Linux

By default, every put in bundle model has a precedence of 100 and a non-installed bundle has a precedence of 500. The identical bundle could have multiple model with a unique precedence. APT installs the model with larger precedence except the put in model is newer.

If this doesn’t make sense, it’s okay. It is going to be extraordinarily uncommon for an everyday Linux consumer to dwell this deep into bundle administration.

Test dependencies and reverse dependencies of a bundle

You possibly can examine the dependencies of a bundle earlier than (and even after) putting in it. It additionally reveals all of the potential packages that may fulfill the dependency.

apt-cache relies upon bundle

How to Use apt-cache Command in Linux

You might also examine which packages are depending on a sure bundle by checking the reverse dependencies with apt-cahce.

How to Use apt-cache Command in Linux

Frankly, I used to be additionally stunned to see {that a} DevOps instrument like Ansible has a dependency on a humorous Linux command like Cowsay. I feel it’s maybe as a result of after putting in Ansible, it shows some message on the nodes.

Test unmet dependencies

You could get troubled with unmet dependencies concern in Ubuntu or different Linux. The apt-cache command gives choice to examine all of the unmet dependencies of varied out there packages in your system.

apt-cache unmet
How to Use apt-cache Command in Linux


You possibly can checklist all out there packages with the apt-cache command. The output could be big, so I recommend combining it with wc command to get a complete variety of out there packages like this:

apt-cache pkgnames | wc -l

Did you discover that you just don’t should be root consumer for utilizing apt-cache command?

The newer apt command has a couple of choices out there to match the options of apt-cache command. Since apt is new, apt-get and its related instructions like apt-cache are nonetheless most popular for use in scripts.

I hope you discover this tutorial useful. When you have questions on any level mentioned above or suggestion to enhance it, please let me know within the feedback.


apt-get list available versions,"sudo apt-get install -f",how to install things with apt,apt search installed packages,apt cache clean,failed to update apt cache,apt cache server,apt-cache vs apt-get,apt-cache madison,apt cache location,apt-file,apt-secure,apt cache verbose,apt cache 8,apt cache directory,apt front-end,aptitude gui ubuntu,apt-get "-y" meaning,apt install -y meaning,apt-get clean cache,apt-get clean autoclean,apt-get -y option,raspbian apt cache,apt search online,apt list available packages versions,apt-cache search version,apt search package version,python-pip-whl,sudo apt-get upgrade,install apt-get mac,install apt-get on linux from scratch,apt-get update package,install apt-get centos,apt-cache depends,apt-cache rdepends,apt-cache policy change candidate,apt-cache depends recursive,apt_preferences,apt-get command,apt-cache command not found,apt-cache search,apt-get install options,apt-get install -y flag

More Stories
How to upgrade to Ubuntu 20.04 From Ubuntu 18.04 to Ubuntu 19.10 Right now