Setting up a Ubuntu server to update automatically sounds good… the question is, how does one accomplish it?
In order to keep your data and server secure, it’s recommended that you routinely update your servers. Ubuntu is no different.
Without installing security patches or software updates, you leave your servers open to hackers and intruders. So, go and update your servers.
If you don’t have all the time in the world to do that on Ubuntu servers, follow the guide below to configure Ubuntu to install security updates and patches automatically.
You won’t have to worry again about patching Ubuntu.
Step 1: Install Ubuntu Auto Upgrade Package
In order to configure Ubuntu to automatically update, you must first install its upgrade/update package. To do that, run the commands below.
sudo apt-get update
sudo apt-get install unattended-upgrades
Step 2: Configure Ubuntu to automatically update
After installing the package above, navigate to the file below and open with your favorite editor.
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
Then look for the lines below and adjust according to your needs
// Automatically upgrade packages from these (origin:archive) pairs
If you wish to block other packages from updating automatically, configure the section below:
// List of packages to not update (regexp are supported)
There are other parameters you can configure like rebooting the server automatically after installing and more. To enable a particular setting, just remove the double slashes // on each line.
Save the file when you’re done.
Finally, navigate to the file below and open with your favorite editor.
sudo nano /etc/apt/apt.conf.d/10periodic
Then, edit the lines as shown below.
Save the file and you’re done.
This is how you configure Ubuntu to automatically install updates