Ubuntu Enable & Set up Automatic Unattended Security Updates

In Ubuntu, you can enable and set up automatic unattended security updates using the unattended-upgrades package. Here are the steps to do this:

  1. Install the unattended-upgrades package:
sudo apt-get install unattended-upgrades
  1. Configure the package to automatically download and install security updates by editing the configuration file located at /etc/apt/apt.conf.d/50unattended-upgrades.
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
  1. Find the line that starts with “Unattended-Upgrade::Allowed-Origins” and make sure that it includes the “origin=Ubuntu,” and “label=Ubuntu” fields for security updates, like this:
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}";
"${distro_id}:${distro_codename}-security";
"Ubuntu:18.04";
};
  1. Save and close the file.
  2. Enable unattended upgrades by running the following command:
sudo dpkg-reconfigure -plow unattended-upgrades
  1. To see the status of the unattended upgrades run this command
sudo unattended-upgrade -d --dry-run
  1. To schedule a daily automatic updates you can use crontab
sudo crontab -e

and add this line

0 3 * * * unattended-upgrade -d

This will run updates at 3:00 AM every day.

Your Ubuntu system will now automatically download and install security updates without any user interaction. You can check the status of updates by running the command apt-get upgrade -s.

It’s important to note that this method is only applied to security updates and not all updates, if you want to apply the same method to all updates you can modify the configuration file to include all updates.

Leave a Comment