How to Install DNF Automatic on Fedora 39/38/37 Linux

DNF Automatic is a CLI tool that is designed to upgrade packages on a Linux system. Unlike the standard dnf upgrade command, DNF Automatic is specifically designed to be run automatically and regularly from systemd timers, cron jobs, and similar tools. With DNF Automatic, you can synchronize package metadata, check for updates, and download and install updates automatically.

What is DNF Automatic?

DNF Automatic is an alternative to the dnf upgrade command that is specifically designed to be run automatically and regularly. The configuration file or the function-specific timer units usually control the tool. The command only accepts a single optional argument pointing to the config file and some control arguments intended for use by the services that back the timer units. If no configuration file is passed from the command line, /etc/dnf/automatic.conf is used.

Install DNF Automatic

To install DNF Automatic on Fedora, open a terminal and run the following command:

sudo dnf install dnf-automatic

Configure DNF Automatic

To customize the behavior of DNF Automatic, you can edit the configuration file located at /etc/dnf/automatic.conf. The configuration file is separated into topical sections, including the [commands] section, the [emitters] section, the [command] section, and the [email] section.

The guide will use the nano editor to open the configuration file:

sudo nano /etc/dnf/automatic.conf

[commands] section

In the [commands] section, you can set the mode of operation of the program. Here are some examples of the options you can customize:

To enable automatic downloading and installation of updates, set apply_updates and download_updates to True:

[commands]
apply_updates = True
download_updates = True

To specify a random delay before downloading updates, set random_sleep to the desired number of seconds:

[commands]
random_sleep = 3600

To specify that only security updates should be installed, set upgrade_type to security:

[commands]
upgrade_type = security

To specify that the system should reboot only when needed, set reboot to when-needed:

[commands]
reboot = when-needed

[emitters] section

In the [emitters] section, you can choose how the results should be reported. Here are some examples of the options you can customize:

To report the results via email, set emit_via to email and specify the email address in email_to:

[emitters]
emit_via = email
email_to = user@example.com

To report the results to the standard output, set emit_via to stdio:

[emitters]
emit_via = stdio

[command] section

In the [command] section, you can customize the command emitter configuration. Here are some examples of the options you can customize:

To specify a custom command to run after the update is complete, set command_format to the desired command:

[command]
command_format = /path/to/custom/command {body}

To specify custom input to the command, set stdin_format to the desired format string:

[command]
stdin_format = {body}

In this example, {body} specifies that the output of the update should be passed as input to the custom command in its original format.

[email] section

In the [email] section, you can customize the email emitter configuration. Here are some examples of the options you can customize:

To specify a custom email address for the “From” field, set email_from to the desired email address:

[email]
email_from = user@example.com

To specify a custom SMTP server for sending emails, set email_host to the desired hostname:

[email]
email_host = smtp.example.com

With these examples, you can customize the configuration file to suit your needs and enable DNF Automatic to update your system automatically and regularly.

Enable DNF Automatic Timer

To activate DNF Automatic, execute the following command:

sudo systemctl enable --now dnf-automatic.timer

This command initiates the DNF Automatic timer and schedules update checks.

To monitor the DNF Automatic timer’s status, use the following command to inspect the system timer:

systemctl list-timers --all | grep -i 'dnf-automatic'

Example output:

[joshua@fedora-linux ~]$ systemctl list-timers --all | grep -i 'dnf-automatic'
Fri 2023-03-17 06:08:59 AWST 19h left      -                            -                    dnf-automatic.timer          dnf-automatic.service

As illustrated, the timer has 19 hours before initiating the next update check.

Conclusion

DNF Automatic is a powerful tool for automating the update process in Fedora. Configuring it to your needs ensures that your Fedora system remains secure, stable, and up-to-date with minimal effort.

Additional Resources

Here are some relevant links that you may find useful for learning more about DNF Automatic and Fedora Linux:

Share to...