← 返回命令列表

Linux command

unattended-upgrades 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Run unattended upgrades

sudo unattended-upgrades

Simulate upgrades

sudo unattended-upgrades --dry-run

Run with verbose output

sudo unattended-upgrades -v

Run with debug output

sudo unattended-upgrades -d

Configure automatic updates

sudo dpkg-reconfigure -plow unattended-upgrades

Check if automatic updates are enabled

cat /etc/apt/apt.conf.d/20auto-upgrades

说明

unattended-upgrades automatically installs security updates and optionally other upgrades on Debian and Ubuntu systems. It runs daily via systemd timers (apt-daily.timer and apt-daily-upgrade.timer) to keep the system patched without manual intervention. The tool is configured through apt configuration files, primarily /etc/apt/apt.conf.d/50unattended-upgrades for allowed origins and options, and /etc/apt/apt.conf.d/20auto-upgrades for enabling automatic updates. By default, only security updates are installed automatically. Configuration options include email notifications, automatic removal of unused dependencies, automatic reboots if required, and blacklisting specific packages from automatic updates. The tool logs its activity to /var/log/unattended-upgrades/. Both unattended-upgrades and unattended-upgrade commands work identically; one is a symlink to the other.

参数

-d, --debug
Enable extra debug output to /var/log/unattended-upgrades/unattended-upgrades.log.
-v, --verbose
Show verbose output during operation.
--dry-run
Simulate the upgrade process without actually installing packages.
--apt-debug
Enable detailed APT/LibAPT output for debugging.
--minimal-upgrade-steps
Perform upgrade in minimal steps, allowing cancellation with SIGINT between packages. This is the default.
--no-minimal-upgrade-steps
Perform upgrade without minimal steps (all packages at once).
-h, --help
Display help message.

FAQ

What is the unattended-upgrades command used for?

unattended-upgrades automatically installs security updates and optionally other upgrades on Debian and Ubuntu systems. It runs daily via systemd timers (apt-daily.timer and apt-daily-upgrade.timer) to keep the system patched without manual intervention. The tool is configured through apt configuration files, primarily /etc/apt/apt.conf.d/50unattended-upgrades for allowed origins and options, and /etc/apt/apt.conf.d/20auto-upgrades for enabling automatic updates. By default, only security updates are installed automatically. Configuration options include email notifications, automatic removal of unused dependencies, automatic reboots if required, and blacklisting specific packages from automatic updates. The tool logs its activity to /var/log/unattended-upgrades/. Both unattended-upgrades and unattended-upgrade commands work identically; one is a symlink to the other.

How do I run a basic unattended-upgrades example?

Run `sudo unattended-upgrades` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -d, --debug do in unattended-upgrades?

Enable extra debug output to /var/log/unattended-upgrades/unattended-upgrades.log.