How to enable automatic updates on Linux

How to enable automatic updates on Linux

We’ll show you, How to enable automatic updates on Linux. In order to keep the data stored on your server as secure as possible, it is recommended to upgrade the services regularly. Keeping your services up to date is a very easy task and requires a small amount of time, but it is crucial for the safety of your data. You can update the services on your Linux VPS manually or enable automatic updates. Today we will show you how to enable automatic updates on a Linux VPS. Enabling  automatic updates on Linux, is fairly an easy task if you carefully follow the steps in this tutorial.

Before making any changes on your server you should be familiar with the advantages and disadvantages of setting up automatic updates on your server. You can find more information on this topic at https://fedoraproject.org/wiki/AutoUpdates#Why_use_Automatic_updates.3F. Please note that the automatic updates will be applied only to the services provided by the package repositories. The automatic updates will not be applied to the services compiled from source. If you are ready you can proceed with the steps below:

The first thing you need to do is to connect to your Linux VPS via SSH. Once you are connected you can install the package that allows automatic updates to run.

1. Enable automatic updates on CentOS 7

If you are using a CentOS 7 VPS, you should follow the instructions below:

Install the yum-cron package using the yum package manager:

# yum -y install yum-cron

Once yum-cron is installed it is time to configure it. The default configuration file is /etc/yum/yum-cron.conf. You can edit the file using your favorite text editor. The following options should be set:

update_cmd = default
apply_updates = yes

Save the file and restart the service:

# systemctl restart yum-cron

Enable the service on system boot:

# systemctl enable yum-cron

That’s it.

You can find more information and configuration options at https://fedoraproject.org/wiki/AutoUpdates

2. Enable automatic updates on Ubuntu 16.04

If you are using a Ubuntu 16.04 VPS, you should follow the instructions below:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS

Install the unattended-upgrades package using the apt package manager:

# apt-get install unattended-upgrades

Once the package is installed you are ready to configure the service. To configure unattended-upgrades you should edit the /etc/apt/apt.conf.d/50unattended-upgrades file using a text editor of your choice. You need to adjust the following options to fit your needs:

Unattended-Upgrade::Allowed-Origins {
        "Ubuntu xenial-security";
//      "Ubuntu xenial-updates";
};

There is an option to blacklist certain packages if you do not like to be automatically updated. To blacklist a package it should be added to the list:

Unattended-Upgrade::Package-Blacklist {
      "vim";
      "libc6";
};

Next, to enable the automatic updates you should edit the /etc/apt/apt.conf.d/10periodic file using a text editor of your choice and adjust the configuration options to fit your needs .

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";

More information and configuration options you can find at https://help.ubuntu.com/lts/serverguide/automatic-updates.html


Of course, you don’t have to enable automatic updates on Linux, if you use one of our VPS hosting services, in which case you can simply ask our expert Linux admins to help you enable automatic updates on your Linux server. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, on how to  enable automatic updates on Linux, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment