Unattended-upgrades on Ubuntu and Debian: set it up and prove it's working
On Ubuntu Server, unattended-upgrades is installed and turned on by default and installs security updates once a day. On Debian, install it and run sudo dpkg-reconfigure -plow unattended-upgrades.
“Enabled” isn't the same as “working”. Check four things: both APT::Periodic settings are "1", both apt timers are active, the allowed origins include your security archive, and the log shows a recent successful run. It never reboots by default, so kernel fixes wait until you reboot.
What unattended-upgrades does, and what it doesn't
unattended-upgrades is the Debian and Ubuntu package that installs updates without anyone logging in. Two systemd timers start it, a couple of apt settings switch it on, and one config file decides which archives it may install from.
| Out of the box | Ubuntu Server | Debian |
|---|---|---|
| Installed | Yes | Usually not on minimal installs. apt install unattended-upgrades |
| Turned on | Yes (20auto-upgrades is created) | After dpkg-reconfigure -plow unattended-upgrades |
| Installs security updates | Yes (-security, plus Ubuntu Pro ESM archives when Pro is attached) | Yes (<codename>-security) |
| Installs other updates | No: -updates is commented out | Stable point releases yes; -updates commented out |
| Reboots when needed | No | No |
| Runs | Daily, from apt-daily-upgrade.timer (06:00 + up to 60 min random delay) | |
The last two rows cause most of the trouble. Security fixes for the kernel, OpenSSL or glibc are installed on disk, but the server keeps running the old code until it reboots or the service restarts.
Turn on unattended-upgrades
Ubuntu
It should already be on. Check it before you change anything:
$ apt-config dump | grep -E '^APT::Periodic::(Update-Package-Lists|Unattended-Upgrade) '
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
If either line is missing or "0", run sudo dpkg-reconfigure -plow unattended-upgrades and answer Yes. That rewrites /etc/apt/apt.conf.d/20auto-upgrades with both values set to "1" (run daily).
Debian
sudo apt update
sudo apt install unattended-upgrades apt-listchanges
sudo dpkg-reconfigure -plow unattended-upgrades # answer Yes
Debian's default /etc/apt/apt.conf.d/50unattended-upgrades allows the security archive and stable point releases. On our Debian 12 test VM, apt-config dump shows the resulting list:
$ apt-config dump | grep '^Unattended-Upgrade::Origins-Pattern::'
Unattended-Upgrade::Origins-Pattern:: "origin=Debian,codename=${distro_codename},label=Debian";
Unattended-Upgrade::Origins-Pattern:: "origin=Debian,codename=${distro_codename},label=Debian-Security";
Unattended-Upgrade::Origins-Pattern:: "origin=Debian,codename=${distro_codename}-security,label=Debian-Security";
The first line is the stable point releases; the other two are the security archive. Leave it as it is unless you have a reason to change it.
Don't edit 50unattended-upgrades in place if you can avoid it. Package updates may want to replace that file. Put your own settings in a file that sorts after it, such as /etc/apt/apt.conf.d/52unattended-upgrades-local. apt reads the files in order, and two kinds of setting behave differently:
- Single values, such as
Automatic-RebootorMail: the value in the later file wins. - Lists, such as
Allowed-Origins,Origins-PatternandPackage-Blacklist: entries in the later file are added to the defaults. They can't remove or replace a default entry. To replace a whole list, start your file with a line such as#clear Unattended-Upgrade::Origins-Pattern;and then write the full list.
Check that it's actually working (5 checks)
Everything below is read-only. Run it on a server you think is patching itself.
1. Both timers are active
$ systemctl list-timers apt-daily.timer apt-daily-upgrade.timer
NEXT LEFT LAST PASSED UNIT ACTIVATES
Sun 2026-11-15 01:28:36 UTC 9h Sat 2026-11-14 12:31:51 UTC - apt-daily.timer apt-daily.service
Sun 2026-11-15 06:07:12 UTC 13h Sat 2026-11-14 12:30:20 UTC - apt-daily-upgrade.timer apt-daily-upgrade.service
Both timers should be listed with a time under NEXT. If one is missing, check systemctl is-enabled apt-daily-upgrade.timer; a masked timer never runs.
2. The periodic settings are “1”
Use the apt-config dump command from the section above. It shows the merged result of every file in /etc/apt/apt.conf.d/, so a later file that sets a value back to "0" shows up here, even if 20auto-upgrades looks right.
3. The allowed origins include your security archive
$ sudo unattended-upgrade --dry-run --debug 2>&1 | grep -E 'Allowed origins|No packages found|Packages that will be upgraded'
Allowed origins are: o=Ubuntu,a=noble, o=Ubuntu,a=noble-security, o=UbuntuESMApps,a=noble-apps-security, o=UbuntuESM,a=noble-infra-security
No packages found that can be upgraded unattended and no pending auto-removals
You want -security for your release in that list (noble-security on 24.04, bookworm-security on Debian 12). An empty list means unattended-upgrades runs every day and installs nothing.
4. The last run succeeded
$ sudo tail -n 3 /var/log/unattended-upgrades/unattended-upgrades.log
2026-11-14 13:56:07,443 INFO Allowed origins are: o=Ubuntu,a=noble, o=Ubuntu,a=noble-security, ...
2026-11-14 13:56:07,444 INFO Initial blacklist:
2026-11-14 13:56:08,506 INFO No packages found that can be upgraded unattended and no pending auto-removals
Look at the dates as well as the messages. A log whose newest line is weeks old means the job isn't running. Lines such as Lock could not be acquired or dpkg --configure -a mean it runs but fails. The systemd side is in journalctl -u apt-daily-upgrade.service.
5. Nothing is waiting that should have been installed
$ apt list --upgradable 2>/dev/null | grep -- -security
If this lists packages from the security archive and the last run was more than a day ago, something is stopping them: a hold, a blacklist entry, a config-file prompt, or an upgrade that would need another package removed. Our guide on checking for security updates goes further and shows which CVEs each update fixes.
How unattended-upgrades fails silently
None of these failures prints a warning anyone would see.
| Failure | What it looks like | Fix |
|---|---|---|
| Empty or wrong allowed origins | The log says “No packages found” every day while apt list --upgradable shows security updates | Restore the default origins; on Debian 11+ the security suite is <codename>-security, so old patterns written for <codename>/updates no longer match |
| Timer disabled or masked | No new log lines; the timer is missing from list-timers | sudo systemctl unmask apt-daily-upgrade.timer then sudo systemctl enable --now apt-daily-upgrade.timer |
| A periodic value set to “0” | apt-config dump shows "0", often from a file added by an image or a config tool | Find the file with grep -r Periodic /etc/apt/apt.conf.d/ and fix it |
| Runs but fails | Lock could not be acquired, a dpkg interruption, or a broken third-party repo in the log | Fix the underlying apt problem, then run sudo unattended-upgrade -d once by hand |
| Held or blacklisted packages | apt-mark showhold lists them; they never update | Review each hold; plan a manual update for the ones you need to keep |
| Installed but never running | /var/run/reboot-required exists; uname -r is older than the newest installed kernel | Plan a reboot (see the next section) |
Reboots: the part unattended-upgrades leaves to you
When an installed update needs a reboot, Ubuntu and Debian create /var/run/reboot-required, and /var/run/reboot-required.pkgs lists the packages that asked for it:
$ cat /var/run/reboot-required.pkgs 2>/dev/null || echo "no reboot needed"
no reboot needed
You have two choices:
- Let unattended-upgrades reboot. In your local config file, set
Unattended-Upgrade::Automatic-Reboot "true";andUnattended-Upgrade::Automatic-Reboot-Time "03:30";. Without a time, it reboots as soon as the run finishes.Automatic-Reboot-WithUsers "false";skips the reboot while someone is logged in. - Plan reboots yourself. This is better for databases and single servers that can't drop connections at random. Check the flag file daily and reboot in a maintenance window. Our reboot guide covers scheduling a reboot and checking the server came back.
Until the reboot, the old kernel is the one that matters for security. Check the running kernel version and compare it with the newest installed one.
Choose which updates it installs
- Security only (default). Recommended for most servers.
- All stable updates. Add the
-updatesarchive in your local file (below). More fixes arrive sooner, and so do more behaviour changes. - Exclude packages.
Unattended-Upgrade::Package-Blacklisttakes regular expressions, for example"postgresql-";for a database you upgrade by hand. - Get a report.
Unattended-Upgrade::Mail "ops@example.com";withMailReport "on-change"emails what was installed. It needs a working local mail setup.
To add -updates, put the origin in /etc/apt/apt.conf.d/52unattended-upgrades-local instead of uncommenting it in 50unattended-upgrades. Origins are a list, so this adds to the defaults and the security archive stays in. On Ubuntu:
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-updates";
};
On Debian, whose default file uses Origins-Pattern:
Unattended-Upgrade::Origins-Pattern {
"origin=Debian,codename=${distro_codename}-updates";
};
After any change, run sudo unattended-upgrade --dry-run --debug and check the “Allowed origins are” line again.
Turn off unattended-upgrades (if you really need to)
For a server where every change goes through your own patch process, switch it off rather than removing the package. Then the settings are easy to turn back on.
sudo dpkg-reconfigure -plow unattended-upgrades # answer No
apt-config dump | grep 'APT::Periodic::Unattended-Upgrade '
APT::Periodic::Unattended-Upgrade "0";
If you turn it off, something else has to install security updates on a schedule. Otherwise the server drifts: each day it misses more fixes, and nothing tells you.
AlmaLinux, Rocky Linux and RHEL: dnf-automatic
The RHEL family uses dnf-automatic instead. Its main trap is the default setting apply_updates = no in /etc/dnf/automatic.conf, so the plain dnf-automatic.timer only downloads updates. Either set apply_updates = yes, or enable dnf-automatic-install.timer, and set upgrade_type = security if you want security fixes only.
How we checked this: Ubuntu 24.04.5 LTS server (unattended-upgrades 2.9.1+nmu4ubuntu1, apt 2.8.4, systemd 255) on 14 Nov 2026 (UTC), with read-only commands and unattended-upgrade --dry-run; Debian 12.15 test VM (unattended-upgrades 2.9.1+nmu3, apt 2.6.2) on 14 Nov 2026 (UTC), with read-only commands only: its packaged 50unattended-upgrades, the merged origins from apt-config dump, and the apt timers. How a later config file combines with the defaults comes from apt.conf(5) and the unattended-upgrades README, not from a test. Anything we didn't run ourselves comes from the official documentation listed under Sources.
Check that auto-patching is really working
unattended-upgrades-check runs 12 read-only checks over SSH on Ubuntu, Debian, AlmaLinux and Rocky Linux servers (unattended-upgrades or dnf-automatic) and gives each server a PASS, WARN or FAIL. Free and open source (Apache-2.0).
Check which CVEs are really open on your server
HostCrust Patch Proof compares every installed package with your distribution's own security data. It counts fixes your distro backported and checks the kernel that is actually running, not just the one on disk. Read-only, no root, free.
FAQ
Does unattended-upgrades reboot the server?
Not by default. Unattended-Upgrade::Automatic-Reboot is "false" on Ubuntu and Debian. When an update needs a reboot (usually a kernel or core library), the server writes /var/run/reboot-required and keeps running the old code until someone reboots it. Set Automatic-Reboot "true" with an Automatic-Reboot-Time, or plan reboots yourself.
Does unattended-upgrades install kernel updates?
Yes. On Ubuntu, kernel security updates come from the -security archive like any other package, so they're installed. The new kernel only runs after a reboot. Until then, uname -r still shows the old one.
How often does unattended-upgrades run?
Once a day. apt-daily-upgrade.timer fires at 06:00 with a random delay of up to 60 minutes. apt-daily.timer, which refreshes the package lists, fires at 06:00 and 18:00 with up to 12 hours of random delay. Both are Persistent=true, so a run missed while the server was off happens at the next boot.
Is it safe to leave unattended-upgrades on for production servers?
For security updates, yes for most servers, and it's safer than leaving known holes open. By default it installs only the security archive (plus stable point releases on Debian), and it skips packages whose config-file changes would need an answer. Put packages you must upgrade by hand in Unattended-Upgrade::Package-Blacklist, and plan reboots.
How do I see what unattended-upgrades would install right now?
Run sudo unattended-upgrade --dry-run --debug. It prints the allowed origins, then the packages it would upgrade, and changes nothing.
Sources
- Ubuntu Server documentation: Automatic updates
- Debian Wiki: PeriodicUpdates (formerly UnattendedUpgrades)
- unattended-upgrades upstream README (a later local file, #clear for lists, and options such as Automatic-Reboot, Package-Blacklist, Mail)
- apt.conf(5) manual, Debian 12: file order, and why lists can't be overridden, only cleared
- unattended-upgrades upstream: the default Debian configuration (50unattended-upgrades.Debian)
- Debian 11 release notes: the security archive is now called <codename>-security
- Ubuntu Pro Client: how to read unattended-upgrades output