This article shows how to set up the dnf-automatic service to apply updates automatically on a Fedora Linux.
If you’re using Fedora as your operating system, keeping your system up to date with the latest software and security patches is important. One way to ensure your system stays current and secure is by setting up automatic updates. This process is simple and only takes a few easy steps.
Fortunately, Fedora provides a ready-made solution to deal with this case that can be quickly and easily implemented without much effort. Following this guide, you can easily set up automatic updates on your Fedora system and never have to worry about manually updating again. So let me show you how.
Step 1: Install the dnf-automatic Package
To enable automatic updates on your Fedora system, you need to install the
dnf-automatic package and then configure it according to your needs. So let’s first install it using the following DNF command:
sudo dnf install dnf-automatic
Step 2: Configure Automatic Updates on Fedora
Now that you have the package installed, you need to make the necessary adjustments to your Fedora system’s automated updates according to your preferences. The configuration file in charge of these settings is
/etc/dnf/automatic.conf. So, use your preferred text editor to open it:
sudo vim /etc/dnf/automatic.conf
Take a look at the “upgrade_type” option. Here you have two choices: “default” and “security.” Let me explain the difference between them.
By using the “default,” all packages are updated. However, this can be risky if some of your applications are sensitive to updates. So you could change it to apply only security updates by replacing the “default” value with “security.”
Nevertheless, if you use Fedora mainly as your desktop system, my recommendation is to stick with the “default” option.
Next, ensure the “apply_updates” option is set to “yes.” By default, its value is “no.” Otherwise, the
dnf-automatic service will only download but not install available updates.
So far, so good. In the next step, you will configure the
dnf-automatic.timer service according to your needs.
Step 3: Setting up the dnf-automatic Timer
Unlike some systemd services,
dnf-automatic is implemented as a timer rather than a service that runs in the background perpetuity. But what are timers? Let me explain. They are systemd unit files that end in “.timer” and control “.service” files or events. In other words, they can be used as an alternative to cron.
Let’s open it for editing using the following command:
sudo systemctl edit dnf-automatic.timer
Next, add the following to the file.
[Timer] OnCalendar=*-*-* 6:00 RandomizedDelaySec=60m
Make sure you insert the snippet exactly where as is shown below. Here, the automatic update process on your Fedora system will start between 6:00 am and 7:00 am. The “RandomizedDelaySec=60m” option is used as a random extra time delta to avoid all of your machines updating simultaneously.
Finally, to enable and start the
dnf-automatic service, use the following command:
sudo systemctl enable --now dnf-automatic.timer
Use the following command to check the status of the automatic update process:
systemctl list-timers *dnf-*
dnf-automatic service will now automatically install updates on your Fedora system. Additionally, you can find more in-depth information on the individual options here.
Setting up automatic updates on Fedora is a straightforward task that can be easily accomplished by following the steps outlined in this article. The
dnf-automatic service keeps your system updated and secured by installing the most recent updates and security patches as soon as they become available.
So, no more having to check for and install updates manually. However, as best practice, you should still manually verify that updates are being applied from time to time.
I hope you found this guide helpful. Any suggestions and comments are welcome in the comments section below.