Enrico Boldori / Wiki

« Go back ⤓ Download

Linux - Ubuntu - Unattended upgrades.txt

# Ubuntu Server 18 Unattended upgrades

## Step 1: package installation

Install the unattended-upgrades package:
apt install unattended-upgrades

## Step 2: configure automatic updates

Edit the configuration file:
vi /etc/apt/apt.conf.d/50unattended-upgrades

Uncomment the following lines by deleting the two slashes at the beginning of it:
"${distro_id}:${distro_codename}";
"${distro_id}:${distro_codename}-security";
"${distro_id}:${distro_codename}-updates";

Optional: You should uncomment and adapt the following lines to ensure you'll be notified if an error happens:
Unattended-Upgrade::Mail "user@example.com";
Unattended-Upgrade::MailOnlyOnError "true";

Recommended: remove unused kernel packages and dependencies:
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";

## Step 3: enable automatic updates

Enable automatic updates and set up update intervals by running:
vi /etc/apt/apt.conf.d/20auto-upgrades

In most cases, the file will be empty. Copy and paste the following lines:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";

The time interval are specified in days, feel free to change the values. Save changes and exit.

## Step 4: check if it works

You can see if the auto-upgrades work by launching a dry run:
unattended-upgrades --dry-run --debug