Manually Enable Automatic Updates on Debian and Ubuntu 14.04 and 16.04 Public Cloud Servers
Keeping your servers up to date with security fixes helps you avoid server compromises. While package updates can't prevent all security breaches, applying updates to your servers should be a key component of your security procedures.
This article describes how to enable automatic updates on your Debian® and Ubuntu® 14.04 and 16.04 for Rackspace public Cloud Servers to ensure that crucial updates are installed and current.
Ubuntu 14.04 and Ubuntu 16.04 have both gone End Of Life, this article is no longer maintained and you should update to a supported version.
Enable automatic updates
Use the following steps to enable automatic updates on your Debian and Ubuntu 14.04 and 16.04 for Rackspace public Cloud Servers:
-
Connect to your Debian or Ubuntu 14.04 or 16.04 server.
-
Run the following command:
sudo apt install unattended-upgrades
The following image shows the output that the command generates:
-
Enter the following command to open the configuration file:
vim /etc/apt/apt.conf.d/50unattended-upgrades
The following image shows what the configuration file looks like:
The lines that begin with two forward slashes (
//
) are comments that are ignored. The configuration options that appear on those lines are placeholders that are inactive. -
In order to enable auto-updates, you need to uncomment the line of code
that has the text"${distro_id}:${distro_codename}-updates";
.Press the i key (for Insert mode) on your keyboard, and then press the down arrow to move the cursor to the forward slashes that appear to the left of
"${distro_id}:${distro_codename}-updates";
. Press the del
key twice.The following image shows that the color of that line of code changes to indicate that it is now active, rather than a comment:
-
If you want to enable other configuration options, use the same steps to uncomment additional lines.
-
After you have made the changes that you want, press the Esc key (as shown in the following image), then type :wq and press Enter or Return to save the configuration file:
A message stating that the file was properly written displays, as shown in the following image:
Configure automatic updates
Use the following steps to configure automatic updates:
-
To set the recurring time for each of the updates, entering the following command to open the configuration file:
vim /etc/apt/apt.conf.d/10periodic
-
Press the i key to enter Insert mode again.
-
Use the arrow keys to move to the line for the update that you want to change, then move to the number between the quotes. This number indicates the interval between updates, in days. Press the del key to delete it.
-
Enter the new number that you want to use for the update interval. The following example shows that three of the updates are performed daily, while the
AutocleanInterval
is every 14 days:When you're finished making changes, press the Esc key, then type :wq and press Enter or Return to save the configuration. A message stating that the file was properly written displays, as shown in
the following image:
Configure notifications for automatic package updates (optional)
You can also choose to set up notifications for automatic package updates, such as time of installation, packages installed, and errors that were generated during the installation process.
Use the following steps to set up notifications:
-
From the command prompt, use the following command:
sudo apt-get install apticron
-
Use the following command to configure the notifications:
vim /etc/apt/apt.conf.d/50unattended-upgrades
-
Scroll to the line of code that has the text
//Unattended-Upgrade::Mail “root”;
and use the arrow keys to move to the forward slashes. Then press the i key and click del twice to remove the forward slashes.The color of the line changes to indicate that it is now active, rather than a comment.
-
Move to the right and press del to delete the word
root
inside of the quotes. -
Between the same set of quotes, enter the email address that you want to use, as shown in the following image:
-
After you're finished making changes, press the Esc key, then type :wq and press Enter or Return to save the configuration.
A message stating that the file was properly written displays, as shown in the following image:
-
Next, enter the following command:
vim /etc/apticron/apticron.conf
-
Scroll to the line of code that begins with
EMAIL
. Press the i key, then move to the right and press the del key to delete the wordroot
between the quotes. -
Between the same set of quotation marks, enter the email address to which you want to send the notifications, as shown in the following image:
-
When you're finished making changes, press the Esc key, then type :wq and press Enter or Return to save the configuration.
A message stating that the file was properly written displays, as shown in the following image:
Updated 12 months ago