How to enable automatic unattended security updates on Ubuntu

Configure your Ubuntu system to install security updates automatically.

We highly recommend that you keep your Ubuntu machine updated with the latest security patches. Updating your Ubuntu on a regular basis will keep your computer safe from various vulnerabilities.

However, manually updating your Ubuntu machine will be time-consuming. Consider handling multiple computers or even a single one, and it is not efficient to perform the updating process manually.

So in this tutorial, we will help you in configuring your Ubuntu machine to be automatically updated via installing the unattended-upgrades package.

Enabling Automatic Unattended Security Updates

Step 1. Install the unattended-upgrades package using the next command, and there is a big chance that you may find the package is already installed.

sudo apt install unattended-upgrades

Install The unattended-upgrade Package
Install The unattended-upgrades Package

Step 2. Now check the status of the unattended-upgrades package.

systemctl status unattended-upgrades

Check The unattended-upgrade Package Status
Check The unattended-upgrades Package Status

If the unattended-upgrades is not running, you can start it using the next command.

systemctl start unattended-upgrades

Step 3. Configure the unattended-upgrades package by editing in the “/etc/apt/apt.conf.d/50unattended-upgrades” Configuration file. Using your favorite editor open the unattended-upgrades configuration file.

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

Open The unattended-upgrade Package Configuration File
Open The unattended-upgrades Package Configuration File

Step 4. After opening the unattended-upgrades configuration file, remove the comment from the “security” line as in the below screenshot, this will let the repository updates automatically.

Edit The unattended-upgrade Package Configuration File
Edit The unattended-upgrades Package Configuration File

In the unattended-upgrades configuration file, you can add packages that you need not updated under the unattended-upgrades::package-blacklist section. But be careful and remember not to write the double slash as they comment the line.

Edit The unattended-upgrade Package Configuration File
Edit The unattended-upgrades Package Configuration File

Also, you will find a section in the configuration file to enable the email notifications in case an error occurs. You can write your email there in case you need to receive information.

The unattended-upgrade Package Email Notifications
The unattended-upgrade Package Email Notifications

After editing in the unattended-upgrades configuration file, save and close it.

Step 5. Now lets enable the automatic updates by editing in the “/etc/apt/apt.conf.d/20auto-upgrades” configuration file.

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

Enable The Automatic Upgrades
Enable The Automatic Upgrades

Step 6. Edit the auto-upgrades file to be like the below screenshot.

Edit The auto-upgrades Configuration File
Edit The auto-upgrades Configuration File

Where:

  • Update-Package-Lists option –> 1 means enable auto-update and 0 disable it.
  • Unattended-Upgrade option –> : 1 means enable auto upgrade and 0 means disable it.

Save and quit the configuration file.

Step 7. Now to verify the previous configurations, we can perform a dry run. The dry run command is used to ensure that the update process is a simulation, and there is no real changes will take place to your packages. Use the next the command to verify the configurations:

sudo unattended-upgrades --dry-run --debug

Test unattended-upgrade Package Configurations
Test unattended-upgrade Package Configurations

Congratulations now you have enabled automatic updates on Ubuntu. Now you can relax and enjoy your Ubuntu time without worrying about the system updates.

Hend Adel
Hi! I'm Hend Adel, a freelancer technical geek with successful experience in Database, Linux and many other IT fields. I help to build solutions to suit business needs and creating streamlined processes. I love Linux and I'm here to share my skills via FOSS Linux! Thanks for reading my article.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

24,438FansLike
181FollowersFollow

LATEST ARTICLES

RECENT COMMENTS

best linux distros programmers
Linux distros have long been a favorite among programmers since the rise in popularity of the OS in the nineties. Programmers are technical by nature, and Linux distros appeal to that technical nature. Let's discuss why Linux is a great desktop OS for programmers and developers, and find out best distros suitable for them.
best video players for linux
Most Linux-based systems come with a built-in video player, but let's be honest, it most definitely won't be able to satisfy all of your requirements, due to the fact that default software is mostly made for basic purposes. In this article, we will review the 5 Best Video Players for Linux and thoroughly discuss their features as well as their pros and cons.
cool and fun linux commands
The real purpose of this article is to help Linux newbies get comfortable and confident with the Linux command-line.  While knowledge and comfort of the Linux GUI allow great power, it is the mastery of the command line, or CLI, affords the Linux user unlimited power and certifies them as a Linux power user well on their way to becoming an expert.