In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Ubuntu apt-cache command how to use, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
What is the apt-cache command for?
The APT package manager works on the local cache of the package metadata. Metadata usually consists of package name, version, description, dependencies, repositories, developers and other information. With the apt-cache command, you can query the local APT cache and get the relevant information.
You can search for a package's availability, its version number, its dependencies, and so on. I will show you how to use the apt-cache command through an example.
The location of the APT cache is the / var/lib/apt/lists/ directory. Which repository metadata is cached depends on which repositories are added to your source list / etc/apt/sources.list file, as well as additional repository files located in the / etc/apt/sources.list.d directory.
Surprisingly, apt-cache does not clear the APT cache. To do this, you must use the apt-get clean command.
Needless to say, the APT packaging system is used on Debian and Debian-based Linux distributions such as Ubuntu, Linux Mint, Elementary OS, and so on. You can't use it on Arch or Fedora.
Use the apt-cache command
Like other Linux commands, apt-cache has some options that you can refer to its man page at any time.
However, you may not need to use all the options. That's why I'll show you only the most common and useful examples of apt-cache commands in this tutorial.
Always update
It is a good idea to update the local APT cache to synchronize with the remote repository. How do you do this? You can use the command:
Sudo apt update search package
The most common use of the apt-cache command is to find software packages. You can use a regular expression to search for packages in the local APT cache.
Apt-cache search package_name
By default, it looks for search keywords in the name and description of the package. It displays the matching packages and their short descriptions in alphabetical order.
You can also narrow your search to find only search terms in the package name.
Apt-cache search-names-only package_name
If you want to know the full details of all matching packages, you can use the-- full flag.
Get detailed packaging information
If you know the exact name of the package (or if you have successfully found it through a search), you can get detailed metadata information about the package.
Apt-cache show package_name
You can see all the details in the package metadata, such as name, version, developer, maintainer, repository, length description, package size, and even checksum.
There is also an option, showpkg, to display information such as the name, version, forward and reverse dependencies of the package.
Strategy of apt-cache showpkg package_nameapt-cache
This is an option that is rarely used in the apt-cache command. The policy option can help you debug problems related to preference files.
If you specify the name of the package, it will show whether the package is installed, in which version of the repository it is available, and its priority.
By default, each installed package version has a priority of 100 and an uninstalled package has a priority of 500. There may be multiple versions of the same package with different priorities. APT installs a higher priority version unless the installed version is newer.
It doesn't matter if you don't understand this part. For the average Linux user, it is rare to dwell on such a deep knowledge of software package management.
Check the dependencies and reverse dependencies of the package.
You can check the dependencies of a package before (or even after) installation. It also displays all packages that may satisfy the dependency.
Apt-cache depends package
You can also check which packages are dependent on a package by checking reverse dependencies through apt-cahce.
Frankly, I was also surprised to see that DevOps tools like Ansible depend on interesting Linux commands like Cowsay. I think it's probably because after installing Ansible, it displays some information on the node.
Check for unmet dependencies
You may be plagued by unmet dependencies in Ubuntu, as do other Linux. The apt-cache command provides an option to check all unmet dependencies of the various available packages on the system.
Apt-cache unmet
Conclusion
You can use the apt-cache command to list all available packages. The output can be large, so I suggest combining it with the wc command to get the total number of available packages, like this:
Apt-cache pkgnames | wc-l
Have you noticed that you don't need to be a root user to use the apt-cache command?
Newer apt commands also have some functional options corresponding to apt-cache commands. Because apt is relatively new, commands such as apt-get and its associated apt-cache are preferred in scripts.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.