使用 apt-get 命令升级几乎所有软件包但“保持”某些软件为当前版本,你可以使用 dpkg 命令。比如我使用 apt-get 命令升级我的 Ubuntu 或者 Debian 操作系统时,会有如下结果:

% sudo apt-get upgrade


apt apt-transport-https apt-utils ghostscript ghostscript-cups ghostscript-x google-chrome-beta hal indicator-applet
nvidia-current-modaliases php-pear php5 php5-cli

如果我不想升级 php5 这个包,我可以“保持”当前这个版本不被升级。

  1. 切换至 root 用户 (su or sudo -s)
  2. 执行:

echo php5 hold | sudo dpkg --set-selections

然后,执行 apt-get upgrade 命令之后,这个包会被“留住”。

% sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages have been kept back:


echo php5 hold | sudo dpkg --set-selections

消息来源:Tomasz Muras: Upgrade all packages but one

Join the Conversation


Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.