Ubuntu releases software updates, security patches, and other critical updates quite frequently. Manually checking for updates and updating the system can become a tedious task and there are chances of missing important updates which can be critical. The user must ensure that Linux machines are updated with the latest “security updates”.
In this article, the setting up of automatic security updates on Ubuntu 22.04 LTS will be discussed.
Prerequisites
In order to follow this article, we will require
- System with Ubuntu 22.04 LTS Installed.
- A user account with sudo privileges.
- A text editor (e.g., Nano)
How to Configure/ Set up Automatic Security Updates on Ubuntu 22.04?
Security updates are regularly released by operating systems including Linux Ubuntu. Security updates resolve the issue(s) that impact the Operating System’s performance. The following steps will be performed in order to set up automatic security updates on Ubuntu:
Step 1: Update System Repositories
We will update existing packages by running the following command:
Step 2: Install unattended-upgrades Package
The purpose of the “unattended-upgradeds” package is to keep the computer up to date with software updates, security patches, and other critical updates. We will install the unattended-upgrade package using the below command:
From the above screenshot, it can be seen that the unattended-upgrade package is installed successfully. We can verify the status of unattended-upgrades by using the below command:
As seen from the above screenshot, the status of the unattended-upgrades package is “active (running)“.
Step 3: Enable the unattended-upgrades Function
We will run the below command to enable the unattended-upgraded function:
After running this command, we will be prompted for a sudo password, After that, we will be guided to the configuration wizard:
Click “Yes” and press Enter. As a result, a new file will be created at the following path: “file /etc/apt/apt.conf.d/20auto-upgrades”.
Step 4: Configure unattended-upgrade for Security Updates
We can configure the update options in the file at path: /etc/apt/apt.conf.d/50unattended-upgrades as follows:
The above screenshot shows the default setup which indicates that security updates will be installed automatically. Security updates are crucial and are sufficient to keep the server up and running.
Bonus Tip 1: How to Set Up Normal Updates on Ubuntu?
If we would like to install normal updates automatically too, then we will edit the file and will un-comment the following line:
After updating the configuration, we will save and close the file by pressing Ctrl+O and Ctrl+X respectively:
Bonus Tip 2: How to View Log Files?
Log files include all tasks done by the “unattended-upgrades” system. We can view the first 100 lines of the log file by running the following command:
The above screenshot shows details of all actions performed by the unattended upgrade system.
Conclusion
In Ubuntu 22.04, automatic security updates are enabled by installing, enabling, and configuring “unattended-upgrade” packages. Security updates are critical for Ubuntu servers. Delaying to install security updates can result in unpleasant consequences. In this article, we have discussed detailed steps for setting up security updates automatically on Ubuntu. Setting up automatic updates can save us from unexpected situations as critical updates will be installed timely.