Ubuntu Server 消息说可以更新包,但 apt-get 不更新任何

Mik*_*e T 55 ubuntu apt

可能的重复:
amazon-ec2 ubuntu 10.04 服务器中的更新

当我登录到 Ubuntu 10.04.2 LTS 服务器时,我看到以下消息:

42 packages can be updated.
18 updates are security updates.
Run Code Online (Sandbox Code Playgroud)

但是当我尝试更新它时,没有任何东西像预期的那样升级:

$ sudo apt-get update
....snip....
Reading package lists... Done
$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages have been kept back:
  linux-generic-pae linux-headers-generic-pae linux-image-generic-pae
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Run Code Online (Sandbox Code Playgroud)

为什么没有任何更新,或者为什么 3(来自 apt-get)的计数与 42 不同?什么软件说42不合适?

(其他细节:这是服务器版,没有GUI;我没有接触过apt配置文件;我安装软件时拒绝允许自动更新)

hmo*_*liu 52

为了安装保留的软件包,您必须运行:

sudo apt-get update && sudo apt-get dist-upgrade
Run Code Online (Sandbox Code Playgroud)

尝试运行sudo apt-get update && sudo apt-get upgrade不会安装保留的软件包,因为apt-get upgrade默认情况下不会尝试安装新软件包(例如新内核版本);从手册页:在任何情况下都不会删除当前安装的软件包,或者检索和安装尚未安装的软件包。

但是apt-get dist-upgrade允许您在需要时安装新软件包(即新内核版本);从手册页:

  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.
Run Code Online (Sandbox Code Playgroud)

  • 这确实更新了三个包,但它没有更改与以前完全相同的 MOTD 消息(“可以更新 42 个包...”)。我不得不通过`sudo rm /etc/motd.tail` 手动重置此消息,现在我正确地看到“0 个包可以更新”。 (4认同)

Cal*_*leb 20

此消息来自 MOTD(每日消息)系统。最近在此答案中详细介绍了如何解决此消息与包管理器之间的不一致问题

  • 并重新启动?我不敢相信我们必须重新启动才能刷新系统消息。而且这个bug已经存在7年多了还没有修复?惊人的。 (2认同)