假设您刚刚通过 SSH 登录到运行 Ubuntu 的服务器。
是否有一个简单的命令来查明无人值守升级是否已启用并将自动安装安全关键更新?
答案1
cat /etc/apt/apt.conf.d/20auto-upgrades
显示是否自动安装
cat /etc/apt/apt.conf.d/50unattended-upgrades |grep -v //
这将向您显示自动安装的内容。默认情况下,它应该安装安全文件。还有其他文件,具体取决于您运行的系统,因此可能需要绕过它们。
答案2
可以在 中查找配置/etc/apt/apt.conf.d/20auto-upgrades
。此外,您还可以检查日志文件/var/log/dpkg.log
。如果无人值守升级正在运行,您应该会在那里看到最近的事件。
让我们看两个示例会话:
机器 1(禁用无人值守升级):
$ cat /etc/apt/apt.conf.d/20auto-upgrades
cat: /etc/apt/apt.conf.d/20auto-upgrades: No such file or directory
$ tail /var/log/dpkg.log
(no output, empty file)
机器 2(启用无人值守升级):
$ cat /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
$ tail /var/log/dpkg.log
2017-06-07 18:35:38 status half-configured linux-generic:amd64 4.10.0.22.24
2017-06-07 18:35:38 status installed linux-generic:amd64 4.10.0.22.24
2017-06-07 18:35:38 configure linux-signed-image-generic:amd64 4.10.0.22.24 <none>
2017-06-07 18:35:38 status unpacked linux-signed-image-generic:amd64 4.10.0.22.24
2017-06-07 18:35:38 status half-configured linux-signed-image-generic:amd64 4.10.0.22.24
2017-06-07 18:35:38 status installed linux-signed-image-generic:amd64 4.10.0.22.24
2017-06-07 18:35:38 configure linux-signed-generic:amd64 4.10.0.22.24 <none>
2017-06-07 18:35:38 status unpacked linux-signed-generic:amd64 4.10.0.22.24
2017-06-07 18:35:38 status half-configured linux-signed-generic:amd64 4.10.0.22.24
2017-06-07 18:35:38 status installed linux-signed-generic:amd64 4.10.0.22.24
(机器 1 运行的是 Ubuntu 16.04,机器 2 运行的是 Ubuntu 17.04。不过,这应该不会有什么区别。)