apt-get 中 --upgradable 的等效命令

apt-get 中 --upgradable 的等效命令

Ubuntu 打印出:要查看这些附加更新,请运行:apt list --upgradable

所以我尝试

$ apt list --upgradable > list.txt

,重定向到一个文件,但它抱怨:

警告:apt 没有稳定的 CLI 界面。在脚本中请谨慎使用。

所以我aptapt-get

$ apt-get list --upgradable > list.txt

但我收到了错误:

E: 命令行选项 --upgradable 与其他选项结合使用时无法理解

那么我应该使用什么命令将可升级列表放入文件中?

编辑 我的 Ubuntu 版本是 Ubuntu 20.04.2 LTS

答案1

至少在 Ubuntu 18.04 中

apt-get --just-print upgrade

例如

me@mypc:~$  apt-get --just-print upgrade
NOTE: This is only a simulation!
      apt-get needs root privileges for real execution.
      Keep also in mind that locking is deactivated,
      so don't depend on the relevance to the real current situation!
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  linux-generic-hwe-18.04 linux-headers-generic-hwe-18.04 linux-image-generic-hwe-18.04
The following packages will be upgraded:
  google-chrome-stable libnss-systemd libpam-systemd libsystemd0 libudev1 linux-libc-dev systemd
  systemd-sysv udev
9 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Inst libnss-systemd [237-3ubuntu10.45] (237-3ubuntu10.46 Ubuntu:18.04/bionic-updates [amd64]) []
Inst libsystemd0 [237-3ubuntu10.45] (237-3ubuntu10.46 Ubuntu:18.04/bionic-updates [amd64]) [systemd:amd64 ]
Conf libsystemd0 (237-3ubuntu10.46 Ubuntu:18.04/bionic-updates [amd64]) [systemd:amd64 ]
Inst libpam-systemd [237-3ubuntu10.45] (237-3ubuntu10.46 Ubuntu:18.04/bionic-updates [amd64]) [systemd:amd64 ]
Inst systemd [237-3ubuntu10.45] (237-3ubuntu10.46 Ubuntu:18.04/bionic-updates [amd64])
Inst udev [237-3ubuntu10.45] (237-3ubuntu10.46 Ubuntu:18.04/bionic-updates [amd64]) []
Inst libudev1 [237-3ubuntu10.45] (237-3ubuntu10.46 Ubuntu:18.04/bionic-updates [amd64])
Conf libudev1 (237-3ubuntu10.46 Ubuntu:18.04/bionic-updates [amd64])
Conf systemd (237-3ubuntu10.46 Ubuntu:18.04/bionic-updates [amd64])
Inst systemd-sysv [237-3ubuntu10.45] (237-3ubuntu10.46 Ubuntu:18.04/bionic-updates [amd64])
Inst google-chrome-stable [89.0.4389.128-1] (90.0.4430.72-1 Google:1.0/stable [amd64])
Inst linux-libc-dev [4.15.0-141.145] (4.15.0-142.146 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64])
Conf libnss-systemd (237-3ubuntu10.46 Ubuntu:18.04/bionic-updates [amd64])
Conf libpam-systemd (237-3ubuntu10.46 Ubuntu:18.04/bionic-updates [amd64])
Conf udev (237-3ubuntu10.46 Ubuntu:18.04/bionic-updates [amd64])
Conf systemd-sysv (237-3ubuntu10.46 Ubuntu:18.04/bionic-updates [amd64])
Conf google-chrome-stable (90.0.4430.72-1 Google:1.0/stable [amd64])
Conf linux-libc-dev (4.15.0-142.146 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64])

如果您使用sudo某些警告,它们就会消失。

相关内容