Setup Automatic Updates

Set Up Automatic Unattended Updates for Ubuntu 22.04

This page shows how to install security updates automatically when released by the Ubuntu security team.

Linux server security is indeed an essential task for sysadmins. One of the most fundamental ways to keep the server secure is by installing security updates on time to patch

Updating automatic server to avoid loop hole issues to server.

First need to update and upgrade server

Sudo apt update && upgrade

Sudo apt upgrade

Steps to Install and Automatic Unattended update

let’s install the unattended-upgrades package via the apt package manager

sudo apt install unattended-upgrades

sudo systemctl status unattended-upgrades

    sudo apt install update-notifier-common

Configure unattended-upgrades service

Configure Unattended-Upgrades on Ubuntu 22.04

There are two configuration files available to customize and control the working of the Unattended-Upgrades tool. One is 20auto-upgrades and the other is 50unattended-upgrades

Edit file to check Auto update configuration

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

The configurations in the file are commented using the double slash (//). Uncomment or remove the double slash if you want to update a repository or make changes in your settings.

Enable automatic updates

shariq@u22:~$ sudo vi /etc/apt/apt.conf.d/20auto-upgrades

short explanation 

APT::Periodic::Update Package Lists “1”; – Update the package lists, it is similar to running the sudo apt update

APT::Periodic::Unattended Upgrade “1”; –unattended upgrades, similar to the command sudo apt upgrade

Where the value “1″ means the setting is enabled, and if you want to disable it, just change 1 to 0.


sudo unattended-upgrades –dry-run


shariq@u22:~$ sudo unattended-upgrades –dry-run – – debug

Check automatic updates logs

shariq@u22:~$ sudo cat /var/log/unattended-upgrades/unattended-upgrades.log

Leave a Reply

Your email address will not be published. Required fields are marked *