The unattended-upgrades package installs security updates on Ubuntu by itself, once a day, without anyone logging in. On a server that nobody patches by hand every week, it is the cheapest security control you can turn on. This guide shows how to confirm it is active on Ubuntu 24.04, test it without changing anything, decide which updates it may install, handle reboots and read its logs.

We ran the commands in our lab on Ubuntu 24.04 with unattended-upgrades 2.9.1 in November 2026. Outputs are real and trimmed. The lab is a container without systemd, so the timer command comes from the Ubuntu documentation and carries a note.

The short answer

  • Install: sudo apt install unattended-upgrades. Ubuntu Server images usually have it already.
  • Confirm it is on: apt-config dump APT::Periodic should show Unattended-Upgrade "1".
  • Test: sudo unattended-upgrade --dry-run --debug.
  • By default it installs security updates only and never reboots. Kernel fixes wait until you reboot.

Check that unattended-upgrades is enabled

cat /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

The first line refreshes the package lists every day. The second runs the upgrade every day. A "0" on either line means it is off. To see the values APT really uses, after it has read every config file:

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

If the file is missing, create it with those two lines, or run sudo dpkg-reconfigure -plow unattended-upgrades and answer Yes.

The schedule comes from two systemd timers. From the Ubuntu documentation, not run in our lab:

systemctl list-timers 'apt-daily*'

apt-daily.timer downloads and apt-daily-upgrade.timer installs, by default around 06:00 server time with a random delay.

What it may install

The rules live in /etc/apt/apt.conf.d/50unattended-upgrades. This is the default block on 24.04:

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";
//	"${distro_id}:${distro_codename}-updates";
//	"${distro_id}:${distro_codename}-proposed";
//	"${distro_id}:${distro_codename}-backports";
};

Lines that start with // are off. So the default installs from the security pocket and leaves ordinary bug-fix updates (-updates) for you to install by hand. That is a sensible default for production. Third-party repositories, such as Docker’s or a PHP PPA, are not in the list and are never updated automatically unless you add their origin.

To hold back a package you want to upgrade only under supervision, such as a database server, add it to the blacklist in the same file:

Unattended-Upgrade::Package-Blacklist {
    "mysql-server";
};

Test it with a dry run

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

The lines that matter, from our lab run:

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:
Packages that will be upgraded: apt ca-certificates-java gstreamer1.0-plugins-base libapt-pkg6.0t64 libc-bin libc-dev-bin libc6 ...
All upgrades installed

A dry run installs nothing. The “Allowed origins” line confirms what the config resolves to, and the package list shows what the next real run would upgrade. If the list is long, the server has not been patching and the first real run will take a while.

To apply the updates now, without waiting for the timer:

sudo unattended-upgrade -d

Reboots

Some updates, the kernel and core libraries above all, only take effect after a restart. Ubuntu marks this with a file:

cat /var/run/reboot-required

If the file exists, the server is running old code even though the new packages are installed. In our lab it did not exist, and the command printed “No such file or directory”, which is the good answer.

The defaults in 50unattended-upgrades are all commented out, which means no automatic reboot:

//Unattended-Upgrade::Automatic-Reboot "false";
//Unattended-Upgrade::Automatic-Reboot-WithUsers "true";
//Unattended-Upgrade::Automatic-Reboot-Time "02:00";

For a single web server or an office server, turning this on is usually right. Remove the // and set:

Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "02:30";

For a database server, a cluster member or anything that needs a planned restart, leave automatic reboot off and check for the reboot-required file in your monitoring. A server that has waited weeks for a reboot is a common finding in audits.

See what happened

Set a mail address in the same file, and choose to hear only about problems:

Unattended-Upgrade::Mail "admin@yourcompany.com";
Unattended-Upgrade::MailReport "only-on-error";

The server needs a working way to send mail for this. The package always writes its logs:

ls /var/log/unattended-upgrades/
sudo tail -n 20 /var/log/unattended-upgrades/unattended-upgrades.log

unattended-upgrades.log records each run and the packages it chose. unattended-upgrades-dpkg.log holds the installer output, which is where to look when a package fails to configure.

Two more settings worth changing

Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
Unattended-Upgrade::Remove-Unused-Dependencies "true";

Old kernels fill /boot over the months, and a full /boot stops all further kernel updates. These two lines clean up after each run.

What it does not do

  • It does not update software installed outside APT: applications deployed from Git, containers, pip or npm packages, WordPress plugins.
  • It does not move you to a new Ubuntu release.
  • It does not restart every service that uses an updated library. Check with sudo needrestart -r l after a run if you have needrestart installed.
  • It does not tell you about a vulnerability that has no fix yet. Keep reading security advisories for the software you expose to the internet.

Free tool: after patching, see how the site looks from outside with our website safety check. It grades HTTPS, certificate and security headers in about 30 seconds.

Related guides

Sources

Want your servers’ patch and hardening state reviewed? Our Linux server hardening audit reviews accounts, permissions, services and SSH settings on your servers. Contact us for a quote.

Post author avatar

Bhaskar Soni

Bhaskar Soni is a Security Engineer and the founder of Youngster Company, based in Ahmedabad, Gujarat. He works hands-on with Linux server hardening, vulnerability assessment and penetration testing (VAPT), ISO 27001 compliance and OSINT investigations. He writes practical, tested guides for IT professionals and Indian businesses, and every article on this site is written or reviewed by him.

Leave a Reply