ModuleNotFoundError: No module named 'apt_pkg' is how unattended-upgrades died on an Ubuntu 24.04 test container for this post, before it checked a single package. Nothing about the update settings was wrong. Someone had pointed /usr/bin/python3 at Python 3.13, the script’s first line asks for /usr/bin/python3, and the apt bindings on the system were built for 3.12. On a real server that crash would happen once a day inside a systemd timer, and the machine would go on looking patched. Unattended-upgrades is the Debian and Ubuntu package that installs security updates on its own, and most of what goes wrong with it is quiet like that.
What unattended-upgrades does by default
Security pocket only, once a day, no reboots
Ubuntu’s server documentation states that Ubuntu will apply security updates automatically, without user interaction, through the unattended-upgrades package, which is installed by default, and that the run happens once a day. The project README describes the job in one line: This script upgrades packages automatically and unattended.
Two files drive it. 20auto-upgrades switches the daily jobs on, and on the test container it held exactly the two settings the README lists for a manual setup:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
50unattended-upgrades decides what may be installed. On Ubuntu the active origins were:
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}";
"${distro_id}:${distro_codename}-security";
"${distro_id}ESMApps:${distro_codename}-apps-security";
"${distro_id}ESM:${distro_codename}-infra-security";
};
Debian’s shipped config uses a different syntax, Origins-Pattern, and its active lines in the upstream file include origin=Debian,codename=${distro_codename},label=Debian-Security. Both lists pair the base release archive with its security archive. What stays out, per Ubuntu’s docs, is -updates, -proposed and -backports, all commented out, so ordinary bug-fix updates wait for a human.
The installed package on the test container was version 2.9.1+nmu4ubuntu1, whose changelog entry is signed off on February 12, 2024.

Reading the dry run
The debug output says what it will and will not touch
The README’s diagnostic command is sudo unattended-upgrade –debug –dry-run. Once the Python problem from the opening was worked around by calling the interpreter directly, the dry run printed its policy within its first few lines:
$ /usr/bin/python3.12 /usr/bin/unattended-upgrade --dry-run --debug
Starting unattended upgrades script
Allowed origins are: o=Ubuntu,a=noble, o=Ubuntu,a=noble-security,
o=UbuntuESMApps,a=noble-apps-security, o=UbuntuESM,a=noble-infra-security
Initial blacklist:
Initial whitelist (not strict):
Marking not allowed <apt_pkg.PackageFile object: filename:'/var/lib/apt/lists/
archive.ubuntu.com_ubuntu_dists_noble-updates_main_binary-amd64_Packages.lz4'
a=noble-updates,c=main,v=24.04,o=Ubuntu,l=Ubuntu ...>
Applying pin -32768 to package_file: <apt_pkg.PackageFile object: filename:'/var/lib/apt/lists/
archive.ubuntu.com_ubuntu_dists_noble-updates_main_binary-amd64_Packages.lz4' ...>
That -32768 pin is how the tool fences off the noble-updates archive: packages from there are effectively invisible to the run. The a= and o= values come straight from the repository metadata, and apt-cache policy shows the same fields for every source on the machine:
release v=24.04,o=Ubuntu,a=noble-backports,n=noble,l=Ubuntu,c=main,b=amd64
Matching those fields is how a third-party repository gets added to the allowed list, and the dry run with --debug is the cheapest way to confirm that a new origin line matches anything at all. Details of every real run land in /var/log/unattended-upgrades/, which Ubuntu’s documentation names as the place for detailed per-run logs. Those logs grow like any others, and the x9m8 logrotate post covers keeping them in check.
Auto-reboot settings
Patching the kernel is not the same as running the patched kernel
A new kernel, or a new C library, sits on disk until the machine restarts. The tool signals that need through a file, and its config comment warns that Automatic-Reboot will reboot WITHOUT CONFIRMATION if the file /var/run/reboot-required is found after the upgrade. The relevant block on the test container, all commented out by default:
//Unattended-Upgrade::Automatic-Reboot "false";
//Unattended-Upgrade::Automatic-Reboot-WithUsers "true";
//Unattended-Upgrade::Automatic-Reboot-Time "02:00";
Per Ubuntu’s docs, Automatic-Reboot defaults to false, Automatic-Reboot-WithUsers defaults to true, and Automatic-Reboot-Time defaults to now. Read together, those defaults mean that anyone who flips only the first switch gets an immediate reboot, mid-afternoon, with users logged in. Setting a time is the second line people forget.
Ubuntu’s documentation is plain about the trade: Reboots can be very disruptive, especially if the system fails to come back. On a home server with no console access, a kernel that fails to boot after an unattended 2 a.m. restart is a long drive to the closet. Leaving reboots manual means the box runs an old kernel until someone notices the file, which is why a weekly check of /var/run/reboot-required belongs on the same list as the Secure Boot certificate check for anyone with firmware deadlines.

Where people get burned
Every one of these leaves the machine looking patched
A swapped system Python. Tested above. The script’s shebang is #!/usr/bin/python3, and on the test container that name pointed through update-alternatives (manual mode) to /usr/bin/python3.13, while python3-apt shipped only apt_pkg.cpython-312-x86_64-linux-gnu.so. Result: a traceback every run and no updates. Installing a newer Python is fine; repointing the system’s python3 is the part that breaks Debian and Ubuntu tooling.
A leftover file that switches the timer job off. The test container had a file in /etc/apt/apt.conf.d/ named docker-disable-periodic-update containing one line, APT::Periodic::Enable "0";. The daily script honors it:
$ apt-config dump | grep '^APT::Periodic'
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::Enable "0";
$ sed -n 356,360p /usr/lib/apt/apt.systemd.daily
eval $(apt-config shell AutoAptEnable APT::Periodic::Enable)
if [ $AutoAptEnable -eq 0 ]; then
exit 0
fi
20auto-upgrades says yes, a later file says no, and the script exits with status 0, which looks like success to anything watching. Files like this ride along when a VM or container template becomes a long-lived server.
Third-party repositories. Ubuntu’s docs put it in capitals: adding a repository “WILL NOT make unattended-upgrades consider it for updates” until its origin is added to Allowed-Origins. Docker’s packages, a vendor’s database repository, a PPA: none of them are patched automatically by default.
Conffile prompts and blacklists. The README says the tool holds back any package that requires them, meaning a package whose update would ask about a locally edited config file. It also warns that if package A depends on a blacklisted package B, both packages A and B will not be upgraded. A blacklist line added to protect one service can freeze a chain of others.
Machines that sleep through the schedule. The timers apt-daily.timer and apt-daily-upgrade.timer run at a scheduled time with a random delay, and Ubuntu notes that a missed run may happen at the next boot, where it can prevent other package operations from taking place at that time. A laptop server switched on in the morning may refuse an apt install for a few minutes for exactly that reason.
Containers. On the test container, PID 1 was not systemd, so no timer would ever fire there. Installed inside a container like that one, unattended-upgrades is a fire extinguisher bolted to a wall in a building nobody enters.
The risk debate
Patching too slowly has a price; patching blind has a few scars
The case for automatic security updates rests on what happens without them. The U.S. Government Accountability Office’s report on the 2017 Equifax breach describes a known Apache Struts flaw that was not properly identified as being present on the online dispute portal, an intrusion that lasted for about 76 days before it was discovered, and at least 145.5 million individuals affected. Struts was not an apt package, so unattended-upgrades would not have saved Equifax. The failure the report describes is the one the tool exists to remove: a patch notice that went to an out-of-date recipient list and never reached the people responsible for installing the fix.
Against it stands a subtler point. Automatic installation means trusting whatever the archive publishes, the moment it publishes it. In March 2024, CISA reported malicious code being embedded in XZ Utils versions 5.6.0 and 5.6.1, a compression library that sits under a great deal of Linux. A machine auto-updating from a fast-moving channel would have pulled it in without a human looking.
The record of that incident cuts toward the default config, though. CERT-EU’s advisory listed Debian testing, unstable and experimental among affected distributions and noted the code was mainly distributed in testing versions of the distributions, while Ubuntu was among those that said they were not affected. Stable releases that take only their security pocket were the slow lane, and the slow lane is where the backdoor did not arrive. The real exposure belongs to people who uncomment -updates or point the tool at a rolling repository because “more updates” sounds safer.
That leaves the harder version of the risk argument. A security update is still a code change landing on a production box at an hour nobody chose, and when one breaks a service, the first person to find out is a user. Teams that run staging machines can hold production a day behind; a single home server has no staging. The tool cannot make that call. It can only make the default choice, which is security fixes now, everything else later, and reboots never unless someone says so.
The traceback from the opening never reached a log anyone reads. Is there a server on your network right now where the last successful unattended run happened months ago?

Sources
- Ubuntu Server documentation, Automatic updates: https://ubuntu.com/server/docs/how-to/software/automatic-updates/
- unattended-upgrades README (GitHub, mvo5): https://github.com/mvo5/unattended-upgrades
- unattended-upgrades Debian default config (50unattended-upgrades.Debian): https://raw.githubusercontent.com/mvo5/unattended-upgrades/master/data/50unattended-upgrades.Debian
- U.S. GAO, GAO-18-559, Data Protection: Actions Taken by Equifax and Federal Agencies (report page): https://www.gao.gov/products/gao-18-559
- U.S. GAO, GAO-18-559 (PDF): https://www.gao.gov/assets/gao-18-559.pdf
- CISA, Reported Supply Chain Compromise Affecting XZ Utils (CVE-2024-3094): https://www.cisa.gov/news-events/alerts/2024/03/29/reported-supply-chain-compromise-affecting-xz-utils-data-compression-library-cve-2024-3094
- CERT-EU, Security Advisory 2024-032: https://cert.europa.eu/publications/security-advisories/2024-032/
- x9m8, Logrotate explained: https://x9m8.com/logrotate-config-explained/
- x9m8, Secure Boot certificate update: https://x9m8.com/secure-boot-certificate-update-check-before-october-19/
