与 apt-get Upgrade 相比,为什么 apt Upgrade 建议安装更多软件包?

与 apt-get Upgrade 相比,为什么 apt Upgrade 建议安装更多软件包?

apt upgrade与运行apt-get upgrade.

apt upgrade我阅读了一些关于和之间的比较,了解它们之间的区别apt-get upgrade可能是什么,但所有文章都描述它们做同样的事情。

这是我现在跑步时得到的结果apt upgrade

Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  linux-headers-5.4.0-47 linux-headers-5.4.0-47-generic linux-image-5.4.0-47-generic linux-modules-5.4.0-47-generic linux-modules-extra-5.4.0-47-generic motd-news-config
The following packages will be upgraded:
  base-files linux-generic linux-headers-generic linux-headers-virtual linux-image-generic linux-image-virtual linux-virtual ubuntu-server
8 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 74.2 MB of archives.
After this operation, 360 MB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.

这是我的输出apt-get upgrade

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  base-files linux-generic linux-headers-generic linux-headers-virtual linux-image-generic linux-image-virtual linux-virtual ubuntu-server
0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded

好的,所以apt-get upgrade决定保留一些软件包是个好主意,但apt upgrade会很乐意安装它们。有人可以解释为什么会这样以及upgrade如果我想安装最新的安全更新我应该使用哪个路径?

答案1

apt upgrade默认情况下允许在升级过程中安装新软件包,反之则apt-get upgrade不允许。这种级联,因此apt-get upgrade拒绝接触任何升级会导致安装新软件包的软件包;这就是你的情况。

您应该使用它apt upgrade来确保您拥有所有最新的安全更新。在某些情况下,如果更新涉及到,您甚至可能需要apt full-upgrade(或者,它们在这里是等效的)apt-get ...去除包。Debian 常见问题解答直接推荐后者(不使用时aptitude);由于您使用的是另一个发行版,因此您应该遵循该发行版的说明。

也可以看看apt-get Upgrade 阻止内核更新。在 Debian 9 上应用更新的官方说明是什么?

答案2

man 8 apt:

upgrade (apt-get(8))
   upgrade is used to install available upgrades of all packages currently installed on
   the system from the sources configured via sources.list(5). New packages will be
   installed if required to satisfy dependencies, but existing packages will never be
   removed. If an upgrade for a package requires the removal of an installed package the
   upgrade for this package isn't performed.

这使得能够通过安装额外的软件包apt upgrade来升级软件包。apt-get upgrade正如输出中提到的apt upgrade

The following NEW packages will be installed:
  linux-headers-5.4.0-47 linux-headers-5.4.0-47-generic linux-image-5.4.0-47-generic linux-modules-5.4.0-47-generic linux-modules-extra-5.4.0-47-generic motd-news-config

旧版本的联机帮助页使其更明确:

DIFFERENCES TO APT-GET(8)

The apt command is meant to be pleasant for end users and does not need to be 
backward compatible like apt-get(8). Therefore some options are different:
[...]

- The option upgrade has --with-new-pkgs enabled by default.

相关内容