DNF downloads packages from repositories installs, uninstall, and updates packages. It performs automatic dependency resolution for packages you are installing, updating, or removing and installs all packages needed to fulfill dependency requirements. On Fedora, it has been the default package manager since Fedora 22. On RHEL 8.x, it is now the default package manager. DNF provides secure package management by enabling GPG signature verification on GPG signed packages. DNF will not install any package not signed with the correct key for that repository. For backward compatibility, RHEL 8.x has a YUM command also, though it is a link to DNF.

Why DNF?

DNF or Dandified YUM is the next generation YUM. Compared to YUM, DNF has better memory utilization, improved dependency management, and the ability to run using both Python 2 & Python 3.

Package Management with DNF

You must have superuser privileges to use the DNF Command to install, update, or remove the package. Following is a set of DNF commands frequently used by sysadmins.

Searching a package

To search for a package installed or available across all repositories, use For example to search for package Nmap:

Listing packages

To see a list of all installed and available packages: To list all installed packages: $ sudo dnf list installed To list all available packages: For example, to list all MySQL  packages which are available:

Displaying package information

To display information about a package: For example, to display info about httpd server:

Installing packages

Installing a single package

To install a single package and all its non-installed dependencies: For example, to install Nginx: This will install Nginx and all its non-installed dependency requirements.

Installing multiple packages

You can also install multiple packages by adding package names to this command. For example, to install Nginx, PHP & MySQL-server, enter:

Installing a package by its binary filename

If you know the name of the binary file to install, but not the package name, even that is enough to install the relevant package. For example, if you enter: DNF searches and finds the package which provides /usr/sbin/named and prompts you to install it.

Finding which package owns a file

If you know the filename and want to find which package provides it (installed or not), use: For example, to find which package provides named, the binary for DNS server use: 

Removing a package

To remove a package: But be careful, DNF is not able to remove a package without also removing packages which depend on it. To remove package nmap use:

Managing package groups

A package group is a collection of packages that are closely related and serve a common purpose. Installing a package group installs a set of packages, saving a lot of time.

List all package groups

To list all package groups:

List all packages in a group

To list all packages in a group: For example, to view packages in the Security Tools group:

Installing a package group

Installing a group will install all packages in a group. To install a package group use: For example, to install the “Network Servers” group:

Removing a package group

To remove a package group: So, to remove the “Security Tools” package group:

Updating packages

Updating all packages

To update all packages and their dependencies you can use: This installs all updates that can be installed. Both dnf upgrade and dnf update have the same effect, but dnf upgrade is preferred.

Updating a single package

To update a single package, run: For example, to update the python package:

Conclusion

Learning DNF can be rewarding as it is often the fastest way to perform system administration tasks. If interested in learning RHEL 8 then you may check out this Udemy course.

A Quick Guide to DNF Package Manager - 65A Quick Guide to DNF Package Manager - 99A Quick Guide to DNF Package Manager - 52A Quick Guide to DNF Package Manager - 77A Quick Guide to DNF Package Manager - 48A Quick Guide to DNF Package Manager - 11