为什么使用apt-get upgrade而不是apt-get dist-upgrade?

Modified on: Sat, 09 Jun 2018 02:06:53 +0800

我通常使用apt-get update && apt-get upgrade运行我的更新和升级而不是GUI,因为它似乎运行得更快。

但是,我最近注意到我经常收到一条消息,说我的某次升级被阻止了。然后我通常运行dist-upgrade来运行它,它工作正常。据我所知,这个问题及其答案,dist-upgrade做了所有相同的事情,然后是一些。

所以,我的问题是:为什么要使用apt-get upgrade?为什么不一直使用apt-get dist-upgrade?为什么apt-get upgrade甚至存在?

最佳答案

我通常用以下方式升级我的机器:

sudo apt-get update && time sudo apt-get dist-upgrade

以下是man apt-get的摘录。 使用升级保留规则:在任何情况下,当前安装的软件包都不会被删除,或者尚未安装的软件包已被检索和安装。如果这对您很重要,请使用apt-get upgrade 。如果你想让事情“正常工作”,你可能需要apt-get dist-upgrade来确保解决依赖关系。

要扩展您希望升级而不是 dist-upgrade 的原因,如果您是系统管理员,则需要具备可预测性。您可能正在使用apt pinning等高级功能,或者从PPA(也许你有一个内部PPA),有各种自动化来检查你的系统和可用的升级,而不是总是急切地升级所有可用的包。当apt执行无脚本行为时,你会非常沮丧,特别是如果这导致生产服务的停机时间。

upgrade upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version. An update must be performed first so that apt-get knows that new versions of packages are available. dist-upgrade dist-upgrade in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; apt-get has a "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. So, dist-upgrade command may remove some packages. The /etc/apt/sources.list file contains a list of locations from which to retrieve desired package files. See also apt_preferences(5) for a mechanism for overriding the general settings for individual packages.

作者:rduplain

相关问答

添加新评论