It is always advisable to keep the installed packages up to date, especially when it comes to security. In this post, we will see how to setup Automatic Update using the dnf-automatic tool.
DNF tool provides automatic notifications of updates, download updates, and then install them automatically by using systemd timers. Below are three systemd timer units provided by dnf-automatic.
- dnf-automatic-notifyonly.timer: Notifies for available updates.
- dnf-automatic-download.timer: Downloads package updates, but does not install them.
- dnf-automatic-install.timer: Downloads and automatically installs package updates.
The dnf-automatic package is not installed by default on the Linux server, it’s available on the BaseOS repository.
1. Install the dnf-automatic package using the below command:
# dnf install dnf-automatic
2. Configure the DNF Automatic tool by editing the /etc/dnf/automatic.conf configuration file. For example:
# vi /etc/dnf/automatic.conf [commands] upgrade_type = default
On the ‘[commands]‘ section, change the ‘upgrade_type‘ as per the need. You can use ‘default‘ for upgrading all available packages or use the ‘security‘ option to upgrade only security related packages.
3. Enable the systemd dnf-automatic.timer timer unit to start using this service:
# systemctl enable --now dnf-automatic.timer
4. Check the status of the dnf-automatic timer
# systemctl list-timers *dnf-* NEXT LEFT LAST PASSED UNIT ACTIVATES Mon 2020-12-21 14:30:10 IST 55min left Mon 2020-12-21 13:30:05 IST 4min 49s ago dnf-makecache.timer dnf-makecache.service Tue 2020-12-22 06:36:59 IST 17h left Mon 2020-12-21 12:19:37 IST 1h 15min ago dnf-automatic.timer dnf-automatic.service
Here, the dnf-makecache unit will run the dnf-makecache service for updating cache packages, and the dnf-automatic unit will run the dnf-automatic service for downloading package upgrades.
5. For the automatic installation of package upgrades, run the ‘dnf-automatic-install‘ timer service.
# systemctl enable --now dnf-automatic-install.timer