DNF Command on Linux Examples and Usages
Starting from RHEL8, DNF is the default package management utility. It uses the following command line syntax.
#dnf [options] [arguments]
The following table lists important options and their description.
| Command | Description |
| #dnf | Display brief information about important options and switches |
| #dnf list | Display all installed and available-to-install packages from all configured repositories |
| #dnf list installed | Display only installed packages |
| #dnf repoquery --repo LocalRepo_BaseOS | Display all packages available to install on the LocalRepo_BaseOS repository |
| #dnf info perl | Display information about the package perl |
| #dnf install perl | Install the package perl |
| #dnf -y update | Update all installed packages to their latest version |
| #dnf update perl | Update the package perl |
| #dnf remove perl | Remove the package perl |
Let's understand the above options in detail.
Without any option, the dnf command briefly describes all available options.
#dnf

DNF downloads packages from the configured repositories. To view a list of all configured and available repositories, use the repolist option.
#dnf repolist

When you install RedHat Linux, the installation process automatically configures the system to use RedHat's default repositories. You need to purchase an active RedHat subscription to use these repositories. If you have an active RedHat subscription, DNF automatically downloads the latest and updated packages from default repositories. If not, you cannot use RedHat's default repositories. In that case, you can configure a local repository for DNF.
You can check the following tutorial to learn how to configure a local repository from the RHEL installation disk.
How to Configure a Local Repository in RHEL Linux
To view all available packages for installation in all configured repositories, use the repoquery option.
#dnf repoquery

If you want to view all available packages for installation only from a specific repository, you need to specify its name as an argument with the --repo option.
The following command lists all packages from the "LocalRepo_BaseOS" repository.
#dnf repoquery --repo LocalRepo_BaseOS

The list option displays all installed packages and all packages available for installation from all enabled repositories.
#dnf list

This command shows output in three columns: package name, version, and the source repository name. If the package was installed during the RHEL installation, it will display @anaconda in the third column.
To view a list of only installed packages, use the installed option with the list option.
#dnf list installed

You can filter the output of the above command with the grep command. For example, use the following command to view a list of installed packages with the keyword zip in their name.
#dnf list installed | grep zip

To know whether a specific package is installed or available in any configured repository for installation, specify its name with the list option.

To install a package, specify its name as an argument with the install option. It installs the package and its prerequisites. For example, the following command installs the perl package and its prerequisites or dependent packages.
#dnf install perl
The above command resolves dependencies and lists the packages it would install. It calculates the size of the packages and the amount of disk space the installation will consume. By default, this command takes permission from the user before downloading and installing the package and its dependencies. After confirmation, it downloads and installs the packages. It also displays a list of installed packages at the bottom of the output.

To perform an unattended installation, use the -y switch with the install option.
#dnf -y install perl
Use the update option to update all installed packages to their latest available versions.
#dnf -y update
This command will check for updates for all installed packages. If it finds an update for a package, it will update that package to the latest version. If you want to update only a single package, specify its name after the update option. For example, use the following command to update only the perl package.
#dnf -y update perl

To remove a package, specify the package name after the remove option. The following command removes the package perl.
#dnf remove perl

You can use the info option to view information about a specific package.

Conclusion
DNF is the default package management utility on RHEL 8 and later versions. It provides a straightforward command-line interface for installing, updating, removing, and querying packages from configured repositories.
By ComputerNetworkingNotes Updated on 2026-02-15