How to configure automatic package updates on CentOS 8

How to configure automatic package updates on CentOS 8

As most of you agree, security updates are very important. Under Linux, it is always recommended to keep installed packages up to date, especially in terms of security. Generally, users should apply security updates to their Linux systems within 30 days of release.

In this tutorial, we will show you how to set up an automatic update package on CentOS 8. This ensures that the system automatically downloads the package and performs the update without manual intervention.

On CentOS 8 systems, we have two ways to set up automatic update packages. We can use the CLI mode with the utility “dnf-automatic” and a web-based environment that can be implemented through Cockpit Server Management.

Set automatic updates with Dnf-automatic

dnf-automatic is a systematic unit that can download software packages to upgrade and apply them automatically. dnf-automatic provides three different system units to control automatic updates.

Following are the three system units provided by dnf-automatic.

  • dnf-automatic-download.timer is for download only
  • dnf-automatic-install.timer for downloading package updates and installations
  • dnf-automatic-notifyonly.timer notifies only through omitter configuration

dnf-automatic is not installed by default on CentOS systems and can be used in the BaseOS repository.

Install dnf-automatic using the following command.

sudo dnf install dnf-automatic

After the installation is complete, go to the “/ etc / dnf” directory and edit the configuration “automatic.conf”.

cd /etc/dnf/vim automatic.conf

in”[commands]”Section, change” upgrade_type “as needed. You can upgrade all packages using the” default “or you can use the” security “option to upgrade all security-related packages.

[commands]upgrade_type = defaultdownload_updates = yes

in”[emitters]’Section, uncomment the’ system_name ‘option and change the value with your hostname. Then change the ’emit_via’ option to motd so that you will display information about package updates every time you log in.

[emitters]system_name = hakase-centos8emit_via = motd

Other options for the “emit_via” configuration are “stdio” (the default configuration) and “email” (for sending package update information to your email).

Now go to “[email]”Section, and change each configuration as needed.

[email]email_from = [email protected]email_to = rootemail_host = localhost

Save and close.

Download package upgrades automatically

Next, start the dnf automatic timer and add it to the system boot.

sudo systemctl enable --now dnf-automatic.timer

Now check the status of the dnf automatic timer.

sudo systemctl list-timers *dnf-*

You will now see two different systemd unit timers.

The dnf-makecache unit will run the dnf-makecache service to update the cache package, and the dnf-automatic unit will run the dnf-automatic service to download package upgrades.

Now, every time you log into the CentOS 8 server, you will see the downloaded package upgrade summary as motd (message of the day).

Package update message at login

All package upgrades have been downloaded automatically via the “dnf-automatic” timer service.

Automatically install package upgrades

For 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 in the list.

Install timer

Now, with every login to the CentOS 8 server, you will see the package upgrade summary applied as a motd (daily message).

Package update applied

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

Automatic updates via cockpit settings

Open your web browser, type the server IP address, followed by the default cockpit port “9090” and log in with your username and password.

https://10.5.5.70:9090/

After logging in, go to “Software update“Menu and turn on the” Automatic Update “button.

Configure automatic package updates with Cockpit

You will now be asked to install the package “dnf automatic‘, Click’installation‘Button.

Dnf-automatic installation via cockpit

After the installation is complete, choose the type of update that is right for you, and then choose when to update the package.

The installation is complete

The dnf automatic timer is now up and running on the system.

Click “service“Menu and select”Timer“Label.

Services and timers

You will activate the dnf-makecache and dnf-automatic-install timers.

Therefore, you have configured CentOS 8 automatic updates using dnf-automatic through cockpit server management.

reference

  • https://fedoraproject.org/wiki/AutoUpdates
  • https://dnf.readthedocs.io/en/
Sidebar