Ubuntu获取apt已安装和可安装包信息

This blog will tell you how to check the vision before installing a package using apt.

The documentation in Chinese is as follow:

apt-cache 可以查询和显示已安装和可安装软件包的可用信息。
它专门工作在本地的数据缓存上,而这些缓存可以通过比如apt-get 的 'update' 命令来更新。如果距离上一次更新的时间太久,那么它显示的信息可能就会过时。

不过作为交换,apt-cache 不依赖当前软件源的可用性(比如:离线状态)

Briefly speaking, apt-cache (policy) is working on the local data cache, aiming to display which version is currently installed and which versions are available to install, and can be simply updated by "apt update".

Take cmake for instance, run

apt-cache policy cmake

and you'll get info in a format similar to the one below (vary from different configuration)

cmake:
  已安装:(无)
  候选: 3.10.2-1ubuntu2.18.04.2
  版本列表:
     3.10.2-1ubuntu2.18.04.2 500
        500 http://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 Packages
     3.10.2-1ubuntu2 500
        500 http://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/main amd64 Packages

and also, for short,

apt policy cmake

is as the same, and run

apt show cmake

to see the details.

Furthermore,  use

apt install -s cmake

to view the possible vision in a simulative way.

use

apt -V upgrade

-V refer to verbose

Which will show you the current package vs the one to be upgraded.

你可能感兴趣的:(Ubuntu,ubuntu,经验分享,linux)