Automatic security updates (unattended-upgrades, dnf-automatic, livepatch)
Updated November 1, 2026
On Debian/Ubuntu you use unattended-upgrades, on RHEL you use dnf-automatic. Auto-apply only security updates, do everything else by hand. Kernel live patching (livepatch/kpatch) delivers security fixes without a reboot. Skip autoreboot, but keep a notification that a reboot is needed.
Why it matters
Most publicly-known CVEs are exploited within 30 days of disclosure. If updates land once a quarter, the exposure window is huge. But applying everything by hand across a 100-node fleet does not work, you need automation.
The compromise is to install only security updates automatically and apply everything else after QA. This covers 95% of real-world risk and avoids breaking applications with an accidental upgrade of a MySQL major version.
Debian / Ubuntu, unattended-upgrades
The package ships in the base repos. To install it:
apt install unattended-upgrades apt-listchanges
dpkg-reconfigure -plow unattended-upgrades
# → creates /etc/apt/apt.conf.d/20auto-upgradesThe main config is /etc/apt/apt.conf.d/50unattended-upgrades:
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-security"; // security only
// "${distro_id}:${distro_codename}-updates"; // everything else is off
// "${distro_id}ESMApps:${distro_codename}-apps-security";
// "${distro_id}ESM:${distro_codename}-infra-security";
};
Unattended-Upgrade::Package-Blacklist {
"linux-*"; // do not upgrade the kernel
"postgresql-*"; // handle the DB separately
};
Unattended-Upgrade::Mail "ops@example.com";
Unattended-Upgrade::MailReport "on-change";
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
Unattended-Upgrade::Remove-Unused-Dependencies "true";
Unattended-Upgrade::Automatic-Reboot "false"; // do NOT reboot
Unattended-Upgrade::Automatic-Reboot-Time "03:00"; // used if "true"And /etc/apt/apt.conf.d/20auto-upgrades:
APT::Periodic::Update-Package-Lists "1"; // apt update
APT::Periodic::Unattended-Upgrade "1"; // run it
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";A systemd timer apt-daily-upgrade.timer runs it once a day with a random delay (to avoid peaks).
systemctl list-timers apt-daily-upgrade.timer
unattended-upgrade --dry-run -d # debug what would be installedLogs:
/var/log/unattended-upgrades/unattended-upgrades.log
/var/log/unattended-upgrades/unattended-upgrades-dpkg.logRHEL / Fedora / CentOS / rocky, dnf-automatic
This is a standard dnf module:
dnf install dnf-automaticConfig, /etc/dnf/automatic.conf:
[commands]
upgrade_type = security # default | security | minimal
random_sleep = 300 # 0-N seconds delay (anti-thundering)
network_online_timeout = 60
download_updates = yes
apply_updates = yes # actually install (not just download)
[emitters]
emit_via = stdio,email # where to send notifications
system_name = web-01.prod
[email]
email_from = root@web-01.prod
email_to = ops@example.com
email_host = localhost
[base]
debuglevel = 1Then enable the timer:
systemctl enable --now dnf-automatic.timer
# or the "download only, no apply" variant
systemctl enable --now dnf-automatic-download.timer
systemctl enable --now dnf-automatic-notifyonly.timerThere are three timer units, so you pick the behavior you want.
SUSE, zypper-automatic / yast2-online-update
zypper install yast2-online-update-configuration
yast online_update_configurationOr cron:
0 3 * * * /usr/bin/zypper -n patch --category securityKernel live patching, updating the kernel without a reboot
The most painful CVEs are at the kernel level (privilege escalation). They require a new kernel → reboot → downtime.
Live patching lets you inject a hotfix into the running kernel without rebooting. The technology works like this:
- The patch is compiled into a kernel module
- The kernel loads the module through the
livepatchAPI - Ftrace redirects calls from the old function to the new one
Providers:
| Provider | Distro | Type |
|---|---|---|
| Canonical Livepatch | Ubuntu (free for up to 5 machines with UA) | proprietary |
| kpatch | RHEL/CentOS/Fedora | open-source + RH patches |
| kGraft | SUSE Enterprise (legacy) | merged into Linux |
| TuxCare KernelCare | universal | commercial |
Canonical livepatch (Ubuntu)
sudo snap install canonical-livepatch
sudo canonical-livepatch enable <token> # token from ubuntu.com/security
sudo canonical-livepatch statusFree tier, up to 5 machines. It is set up through Ubuntu Pro.
kpatch (RHEL/Rocky/AlmaLinux)
dnf install kpatch
systemctl enable --now kpatch
# patches arrive as kpatch-patch-<kernel-version>.rpm
dnf install kpatch-patch-5.14.0-362.13.1Or a Red Hat Enterprise Linux for Live Patching subscription.
When live patching does not fit
- A large change (a new syscall, a new subsystem) is not livepatch-able. Only a reboot helps.
- Userspace updates (libc, openssl) are not helped by livepatch, you have to restart the processes. Use
needrestart(Debian) ordnf needs-restarting. - Initramfs / bootloader are never live.
So you still have to plan reboots, just less often: once a quarter or after a large CVE window.
Reboot strategy
In a cluster with redundancy:
- Drain the node (k8s
kubectl drain, or pull it out of the LB) - Apply the pending kernel update / reboot
- Wait for healthy
- Uncordon → next node
- Roll through all of them.
Tools:
- kured (Kubernetes Reboot Daemon), a DaemonSet that watches
/var/run/reboot-requiredand performs a rolling reboot - system-reboot Ansible playbook
- AWS Systems Manager Patch Manager, for cloud VMs
It looks simple, but in production with 100+ nodes the coordination is critical: without kured you end up rebooting the whole control plane at once.
Userspace restart, needrestart / needs-restarting
After an update, processes keep using the old .so files:
$ openssl version
OpenSSL 3.0.13 # new
$ ls -la /proc/$(pgrep nginx)/maps | grep libssl
→ libssl.so.3.0.11 (old, deleted from disk but still loaded)The fix:
# Debian/Ubuntu
apt install needrestart
needrestart -r i # interactive: what to restart?
needrestart -r a # auto-restart
# RHEL
dnf install yum-utils
needs-restarting -r # is a reboot required?
needs-restarting -s # which services?You can configure unattended-upgrades together with needrestart so that services restart automatically (with a whitelist).
Checking status in production
# How many security updates are pending?
apt list --upgradable 2>/dev/null | grep -i security | wc -l
# On RHEL
dnf updateinfo list security
# When did the last auto-upgrade run?
grep "Run install" /var/log/unattended-upgrades/unattended-upgrades.log | tailA metric for monitoring (Prometheus node-exporter): apt_upgrades_pending, apt_upgrades_pending_security. Alert if security is >0 for more than 24h.
When things go wrong
unattended-upgradesdoes not run: check/etc/apt/apt.conf.d/20auto-upgrades, it must contain the lineAPT::Periodic::Unattended-Upgrade "1";. Otherwise rundpkg-reconfigure.Cache has broken packagesduring an auto-upgrade is a dependency conflict, and it stays pending. Fix: runapt --fix-broken installby hand.- dnf-automatic installs everything, not just security: in
automatic.confupgrade_type = default. Change it tosecurity. - A service is not restarted after a lib update:
needrestartis not configured, or it is on the blacklist. Check/etc/needrestart/conf.d/*. - The
reboot-requiredfile is created, but nobody reboots: if there is no kured or reboot cron, the nodes pile up updates. Visibility: Prometheusnode_reboot_required. - Livepatch is applied, but
uname -rshows the old kernel: this is normal. Usecanonical-livepatch statusorcat /proc/sys/kernel/osrelease. - An old LTS has no updates but the CVE exists: this is an EOL distro. Migrate to a supported one or pay for extended support (Ubuntu ESM, RHEL EUS).
Commands
unattended-upgrade --dry-run -d: Debug mode: shows what would be installed right now, without making real changessystemctl list-timers apt-daily-upgrade.timer: When the auto-update last ran and when it runs nextapt list --upgradable 2>/dev/null | grep -i security: Only security updates that are pending, a quick perimeter checkdnf updateinfo list security: RHEL/Rocky, all pending security updates with CVE numbersneedrestart -r a: Auto-restart every process holding stale .so files after a lib updatesudo canonical-livepatch status: Current state of kernel livepatch on Ubuntu, which patches are appliedls /var/run/reboot-required && cat /var/run/reboot-required.pkgs: Whether a reboot is needed and because of which packages, the standard Debian marker