您如何看待可用于更新的软件包

FreeBSD用户加入你的行列。 我被要求照顾运行10.04 LTS的Ubuntu服务器。

我从/usr/lib/update-notifier/update-motd-updates-available看到服务器上有很多更新但是我没有看到告诉哪些更新的方法。

有人能够指出我正确的方向,以便我可以看到当我运行apt-get upgrade时哪些包会更新?

更新:

目前无法回答我自己的问题所以暂时把它放在这里:

除了下面建议的apt-get upgrade --dry-run/usr/lib/update-notifier/apt-check -p将列出所有可用更新的软件包。

您可以安装aptitude如果尚未安装)。 它是在无头设置中管理包的一个很好的工具。

在此处输入图像描述

否则,如果您只想查看运行时会发生什么,请使用--dry-run参数,它实际上不会执行任何操作,它只会告诉您它将执行的操作:

来自apt-get手册页

 -s, --simulate, --just-print, --dry-run, --recon, --no-act No action; perform a simulation of events that would occur but do not actually change the system. Configuration Item: APT::Get::Simulate. Simulate prints out a series of lines each one representing a dpkg operation, Configure (Conf), Remove (Remv), Unpack (Inst). Square brackets indicate broken packages with and empty set of square brackets meaning breaks that are of no consequence (rare). 

以这种方式将命令添加到命令

 apt upgrade --dry-run 

截至目前(Ubuntu 16.04),您可以使用带有--upgradable标志的apt list ;

 sudo apt update apt list --upgradable 

并且您将获得包含所有可升级包的列表。

另一种选择是将aptitude与搜索词一起使用:

 aptitude search '~U' 

(注意大写的’U’)

这意味着:“搜索已安装且可升级的所有软件包”。 参考: aptitude用户手册

默认情况下, aptitude search为每个包显示其名称,描述和一些标志,但您也可以根据需要调整输出。 例如,要仅列出包名称,命令将为:

 aptitude search -F '%p' --disable-columns '~U' 

( – --disable-columns避免在行尾添加填充空格)

下面的命令将显示已安装的软件包列表,这些软件包在存储库中有可用的更新。

 dpkg --get-selections | xargs apt-cache policy {} | grep -1 Installed | sed -r 's/(:|Installed: |Candidate: )//' | uniq -u | tac | sed '/--/I,+1 d' | tac | sed '$d' | sed -n 1~2p