Automatic Package Updates on CentOS 8

  • -

Automatic Package Updates on CentOS 8

Category:Uncategorized

Security updates, are very important.

Under Linux it is always advisable to keep the installed packages up to date, especially when it comes to security.

This ensures that the system automatically downloads packages and performs updates without manual intervention.

The dnf-automatic is systemd units that can download package upgrades and apply them automatically.  The dnf-automatic provides three different systemd units to control the automatic update.

Below are three systemd units provided by dnf-automatic.

  • dnf-automatic-download.timer for download only
  • dnf-automatic-install.timer for download package updates and install
  • dnf-automatic-notifyonly.timer will only notify via the omitter configuration
sudo dnf install dnf-automatic

The dnf-automatic are not installed by default on the CentOS system, it’s available on the BaseOS repository. Install the dnf-automatic

Once the installation is complete, go to the ‘/etc/dnf’ directory and edit the configuration ‘automatic.conf’:

cd /etc/dnf/
nano automatic.conf

On the ‘[commands]’ section, change the ‘upgrade_type’ as you need. You can use ‘default’ for upgrading all packages or use the ‘security’ option to upgrade all packages related security.

[commands]upgrade_type = defaultdownload_updates = yes

On the ‘[emitters]’ section, uncomment the ‘system_name’ option and change the value with your hostname. Then change the ’emit_via’ option to motd, so you will be displayed about package updates on every login.

[emitters]system_name = hakase-centos8emit_via = motd

Save and close.

Automatic Install Package Upgrades

For the automatic installation of package upgrades, you can run the ‘dnf-automatic-install’ timer service.

Start the ‘dnf-automatic-install’ timer service and add it to the system boot.

sudo systemctl enable --now dnf-automatic-install.timer

After that, check the status of the dnf-automatic timer.

sudo systemctl list-timers *dnf-*

You will get the ‘dnf-automatic-install’ timer on the list.

Install timer

Now on every login action to the CentOS 8 server, you will see the summary of package upgrade applied as a motd (message of the day).

Package updates applied

And all package upgrades have been applied automatically through the ‘dnf-automatic-install’ timer service.