Skip to content
Log In Sign Up info@muvcloud.com

What Automatic Updates Do

A timer checks the package repositories once a day and installs the updates you allowed. That closes known holes within a day instead of whenever you next log in. Two limits remain:

  • Running programs: a service keeps using an old library until it is restarted.
  • The kernel: a new kernel is installed, but it runs only after a reboot.

Keep snapshots and backups anyway: an update can, rarely, break an application. See snapshot vs backup.

Ubuntu and Debian: Turn It On

sudo apt install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades

Ubuntu Server usually has the package installed and enabled already. Answer "Yes" to the question about automatic updates. The tool writes /etc/apt/apt.conf.d/20auto-upgrades:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

"1" means every day. Two systemd timers, apt-daily.timer and apt-daily-upgrade.timer, do the work; systemctl list-timers 'apt*' shows when they run next.

Choose What Gets Installed

The rules live in /etc/apt/apt.conf.d/50unattended-upgrades. Ubuntu lists its sources under Unattended-Upgrade::Allowed-Origins: the release, the security pocket, and the ESM security pockets are active, and the updates, proposed, and backports lines are commented out, so in practice only security updates are installed. Debian uses Unattended-Upgrade::Origins-Pattern, with lines for the Debian security archive and the stable release. To keep one package out, add its name to Unattended-Upgrade::Package-Blacklist. Your own settings are safest in a separate file such as /etc/apt/apt.conf.d/52unattended-upgrades-local, which package updates do not touch.

Test with a Dry Run

sudo unattended-upgrade --dry-run --debug

The command name has no final "s". It prints the allowed origins and the packages that would be upgraded, without installing anything.

Reboots and needrestart

To reboot automatically when an update needs it, add these lines to your local file:

Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "04:00";

The reboot happens only when /var/run/reboot-required exists, at the given time in the server's time zone. The option is off by default. Leave it off if a reboot at that hour would hurt, and reboot by hand instead, as in how to reboot a Linux server.

needrestart, installed on Ubuntu Server and available for Debian, checks after each upgrade which services still use old libraries and restarts or lists them, depending on $nrconf{restart} in /etc/needrestart/needrestart.conf. Run sudo needrestart to see what is pending, including a newer kernel.

AlmaLinux and Rocky Linux: dnf-automatic

sudo dnf install dnf-automatic
sudo nano /etc/dnf/automatic.conf

In the [commands] section, set:

upgrade_type = security
apply_updates = yes

Then start the timer and check it:

sudo systemctl enable --now dnf-automatic.timer
systemctl list-timers 'dnf*'

upgrade_type = security relies on the security notices both distributions publish. The steps are the same on releases 9 and 10, which both ship DNF 4 and dnf-automatic. dnf-automatic.timer follows the file; the variants dnf-automatic-install.timer, dnf-automatic-download.timer, and dnf-automatic-notifyonly.timer ignore its apply and download settings, so enable only one timer. Reboots are off by default (reboot = never); to see whether one is needed, run sudo dnf needs-restarting -r.

Where the Logs Are

SystemLog
Ubuntu, Debian/var/log/unattended-upgrades/
Ubuntu, Debian/var/log/apt/history.log
AlmaLinux, Rocky Linuxjournalctl -u dnf-automatic
AlmaLinux, Rocky Linux/var/log/dnf.log

The first folder holds the tool's own log and the package manager output of each run; the history log lists every package apt installed or removed. To get a report by mail on Ubuntu and Debian, set Unattended-Upgrade::Mail "YOUR_EMAIL";. It needs a working mail setup, as in how to send email from the Linux command line.

Good Practice

  • Check now and then: read the log once a week; a stuck update fails silently.
  • Plan reboots: pending kernels pile up on servers that are never restarted.
  • Update the rest by hand: software from other sources, such as containers or applications you installed yourself, is not covered. Ordinary upgrades are in sudo apt update.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations