How to enable automatic updates on Ubuntu

Life is too short to manually upgrade the packages of your machine twice a week, so here is how to automate the software updates of an Ubuntu server (20.04 or 22.04).

First, you need to install unattended-upgrades:

$ sudo apt install unattended-upgrades

Then configure it:

$ sudo dpkg-reconfigure -plow unattended-upgrades

and select yes on the dialog.

Then, you need to enable automatic updates on a daily basis:

$ vim /etc/apt/apt.conf.d/10periodic
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";

Finally, you may want to disable kernel updates that require a reboot:

$ sudo vim /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Package-Blacklist {
   // The following matches all packages starting with linux-

Unattended-Upgrade::Automatic-Reboot "false";
1 email / week to learn how to (ab)use technology for fun & profit: Programming, Hacking & Entrepreneurship.
I hate spam even more than you do. I'll never share your email, and you can unsubscribe at any time.

Tags: programming, tutorial, linux, devops

Want to learn Rust, Cryptography and Security? Get my book Black Hat Rust!