有时候需要安装特定版本的package,如果自己找source code来build会比较麻烦,如果能用apt install来安装,岂不是很方便。
操作之前,先update:
$sudo apt update
根据包名,获取当前操作系统支持的package 版本:
$apt-cache policy xserver-xorg-core-hwe-16.04
类似于下面的输出:
xserver-xorg-core-hwe-16.04:
Installed: 2:1.19.6-1ubuntu4.1~16.04.2
Candidate: 2:1.19.6-1ubuntu4.1~16.04.2
Version table:
*** 2:1.19.6-1ubuntu4.1~16.04.2 500
500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
500 http://hk.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
100 /var/lib/dpkg/status
Installed表示当前安装的xserver版本,Candidate是server上最新的版本,如果需要安装Candidate的版本:
$sudo apt install xserver-xorg-core-hwe-16.04=2:1.19.6-1ubuntu4.1~16.04.2
这种方式来安装或者update包,会非常方便,而且不用考虑包依赖的问题。