How To Enable Automatic Updates on Linux

Keeping your services up to date is very important and at the same time a very simple task. This requires a small amount of time, and in turn, it is critically necessary in order to secure your data. Before making any changes to 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 automatic updates will only apply to services provided in the repositories.

CentOS 7

If you use CentOS 7 on your VSP, then you must follow the instructions below. First, install the yum-cron package using the yum package manager:

# yum -y install yum-cron

After installation is complete, you must configure it. The default configuration file is /etc/yum/yum-cron.conf. You can edit the file using your text editor. The following parameters should be set further:

update_cmd = default
apply_updates = yes

Save the file and restart the service:

# systemctl restart yum-cron

Enabling the service at system startup:

# systemctl enable yum-cron

Ubuntu 16.04

If you are using Ubuntu 16.04 VPS, you should follow the instructions below. Install the unattended-upgrades package using the apt package manager:

# apt-get install unattended-upgrades

After installing the package, you are ready to configure the service. To configure auto-update, you must edit the /etc/apt/apt.conf.d/50unattended-updates file using the text editor of your choice. You need to configure the following options to suit your needs:

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

There are an option to blacklist some packages if you do not like automatic updates. In order to blacklist a package, it must be added to the list:

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

Next, to enable automatic updates, you must edit the /etc/apt/apt.aptf.conf.d/10periodic file with the text editor of your choice and configure the settings to suit your needs:

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

You can find more detailed information and configuration parameters at https://help.ubuntu.com/lts/serverguide/automatic-updates.html

Was this article helpful?

Related Articles

Leave A Comment?