Skip to main content
Published on November 13, 2026 Turning on automatic security updates on a Linux VPS takes ten minutes. Not doing it costs days of exposure. The latest advisories on this blog make the point. With php2shell, attacks started the same morning the fixes shipped. With the Apache HTTP/2 flaw, the fix exists: what matters is when it lands on your server. With Copy Fail, the patched kernel only protects you after a reboot. The risk is not the vulnerability. It is the gap between a fix being published and a fix being applied. This guide shrinks that gap to hours, on Debian, Ubuntu, AlmaLinux and Rocky Linux.

Which tool for which distribution

Package versions in the official repositories, checked on November 13, 2026: AlmaLinux 10 and Rocky Linux 10 still ship dnf 4, so the configuration below applies to both generations.

Before enabling reboots: take a snapshot

An automatic reboot is a reboot nobody is watching. Take a snapshot from the console before turning it on. If the first reboot goes wrong, you are one click away from a known-good state. Backups remain your baseline protection: a snapshot is a restore point, not a backup.

Set up unattended-upgrades on Debian and Ubuntu

Install and enable

Ubuntu installs unattended-upgrades by default. On Debian, install it. Running the command on either is harmless:
Enabling it lives in /etc/apt/apt.conf.d/20auto-upgrades. Each value is a number of days: 1 for daily, 0 to disable.

Restrict it to security updates

That is already the default, with one nuance per distribution.
  • Ubuntu: Allowed-Origins covers the base release, the -security pocket and the ESM repositories when present. -updates, -proposed and -backports are commented out.
  • Debian: Origins-Pattern covers Debian-Security and your release’s own archive (the one that receives stable point releases). Backports and -updates are commented out.
Leave 50unattended-upgrades alone: the Debian wiki recommends putting your settings in a separate file, 52unattended-upgrades-local, which is read after it. On Debian, if you want security advisories strictly, clear the list and declare it again. An APT list cannot be overridden, only cleared with #clear:
The file Ubuntu ships says it plainly: a security fix can depend on a package from the main archive. That is why the main archive is in the default lists. With the strict filter, such a fix waits: the simulation below shows it.
To see the origins actually configured on your server:

Decide how reboots happen

A patched kernel, C library or systemd only protects you after a reboot. When a package needs one, it creates /var/run/reboot-required. unattended-upgrades reboots only if that file exists and you have allowed it. Append the settings to the local file (it is created if it does not exist yet):
Automatic-Reboot-Time also accepts now (the default) or +m, a delay in minutes. The upgrade itself is triggered by apt-daily-upgrade.timer, set by default to 6:00 with a random delay of up to an hour. To have it run before that night’s reboot, move it earlier:
Keep the random delay: the Debian wiki recommends it so that every server does not hit the mirrors in the same second.

Get an email report

Reports go through the mail command: you need a package that provides it, such as bsd-mailx, and a local mail server that can deliver outside the VPS.
If this test does not arrive, neither will the report. Our guide to SPF, DKIM, DMARC and reverse DNS covers deliverability.

Check it: simulation, timers and logs

Good result: the simulation lists pending security packages without errors, and list-timers shows a next run within 24 hours.

Configure dnf-automatic on AlmaLinux and Rocky Linux

Install

Security only, reboots and email

Everything is set in /etc/dnf/automatic.conf. Change these lines in their respective sections:
With stdio, the report also goes to the systemd journal. With email, dnf-automatic hands the message to the SMTP server named in email_host itself: a local mail server, such as Postfix, must accept it.

Pick the time and enable it

The reboot follows the upgrade by five minutes. Picking the reboot time therefore means picking the timer’s schedule, set by default to 6:00 with a random delay of up to an hour:
The package also ships dnf-automatic-install.timer, which installs regardless of apply_updates, and dnf-automatic-notifyonly.timer, which only notifies. Enable just one.

Check it

sudo systemctl start dnf-automatic.service performs a real run: with the configuration above, it installs the fixes and may reboot the VPS five minutes later. Use the simulation to test.

If the VPS does not come back

It is rare, and everything can be recovered from the console.

Common pitfalls

Services still run the old code. An upgraded package does not replace the process in memory. On Ubuntu 24.04 and later, unattended-upgrades calls needrestart, which restarts the affected services. Elsewhere, list processes using replaced files with sudo dnf needs-restarting on AlmaLinux and Rocky, and restart the services concerned. Our nginx audit routine shows how to spot a process older than its update. Third-party repositories are not covered. The default origins only target the distribution’s own repositories. PHP from an external repository, Docker, nginx.org: their fixes do not go through this mechanism. Add their origin to Origins-Pattern after reading it from apt-cache policy, or follow their advisories yourself. A held package stays held. A package marked with apt-mark hold, or listed in Package-Blacklist, is never upgraded automatically. Check with apt-mark showhold. A manual upgrade waits its turn. While unattended-upgrades is working, it holds the dpkg lock. An apt upgrade started at the same time waits: do not delete the lock. Containers do not follow the host. Docker images carry their own packages. They are updated by rebuilding or pulling a new image, not by the host. The report never arrives. No mail command, no local mail server, or a message rejected by the recipient: send a test email before relying on reports.

Going further

Have a question about a server hosted with us? Our team is available from your client area.