Debian and Ubuntu Automatic Updates

How I set up automatic updates on laptops.

This is a tidier and more reliable (for my machines) version of the official Unattended Upgrades doc.

Install the tool:

sudo apt install unattended-upgrades

Enable it:

vi /etc/apt/apt.conf.d/50unattended-upgrades

Make these changes:

Unattended-Upgrade::Allowed-Origins {
	"*:*";
};

// ...

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

// ...

Unattended-Upgrade::OnlyOnACPower "false";

Enable it again:

vi /etc/apt/apt.conf.d/20auto-upgrades

Put this in that file:

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

You can check your settings by running this:

sudo unattended-upgrade -d --dry-run

OK you’re mostly done, but for non-servers I find this configuration insufficient. If I recall correctly the default only attempts to install updates once a day and it’s at 3am or something. If your laptop is not on at that time, you never get updates. Here’s how I modify the schedule:

sudo systemctl edit --full 'apt-daily*.timer'

I modify the timers to say this:

[Timer]
OnCalendar=hourly
RandomizedDelaySec=5m
Persistent=true

After that change is made, your machine will attempt to install updates hourly. To check out how the timer is working, you can use this command:

systemctl list-timers 'apt-daily*.timer'

Hope this helps!

Posted Thu, Mar 9, 2023

If you're interested in being notified when new posts are published, you can subscribe here; you'll get an email once a week at the most.