20 DNF Commands Every Linux Administrator Should Know

sudo dnf install nginx-1.24.0-1.el9.x86_64

13. Install a Local RPM File

dnf history

sudo dnf downgrade nginx

sudo dnf install /tmp/package.rpm

14. List and Manage Repositories

sudo dnf group install “Development Tools”

If a package’s files are corrupted or accidentally deleted, you can reinstall the package without changing its version:
rpm -V nginx

sudo dnf group remove “Development Tools”

17. Work with Module Streams

dnf repolist

16. Install a Package Group

sudo dnf history redo 12

The dnf history undo command can be a lifesaver when a package change causes unexpected problems. Share this, so your team knows it exists.

12. Downgrade a Package

sudo dnf install nginx

dnf info –installed nginx

7. List Installed Packages

dnf group list

dnf info nginx

On the enterprise side, RHEL 9, Rocky Linux 9, AlmaLinux 9, and RHEL 10 still use DNF (dnf4) as the default package manager. DNF5 has not yet replaced DNF on these systems.
sudo dnf config-manager –enable crb
sudo dnf config-manager –disable epel

Running RHEL 9 or Rocky Linux in production? The RHCSA Certification Course on Pro TecMint covers DNF, repository management, SELinux, storage, and everything in the EX200 exam updated for RHEL 10

15. Add a New Repository

On RHEL and Rocky Linux, DNF4 remains the default and provides full module stream support. DNF5 is not yet the default on RHEL 9, RHEL 10, Rocky Linux, or AlmaLinux, so use the standard dnf commands on those systems.
For RHEL, Rocky Linux, AlmaLinux, and CentOS Stream, getting comfortable with dnf is an essential part of managing modern RPM-based systems. If you’re using Fedora 41 or later, you’ll also want to become familiar with DNF5 and its updated commands.
sudo dnf5 install nginx
sudo dnf5 remove nginx
sudo dnf5 upgrade
sudo dnf5 upgrade nginx

sudo dnf5 config-manager addrepo –from-repofile=https://download.docker.com/linux/rhel/docker-ce.repo

dnf list –installed | grep nginx

dnf search nginx

On RHEL 9 and Rocky Linux 9, DNF modules allow you to work with different versions of a package; for example, Node.js 18 or Node.js 20 without adding third-party repositories:
DNF5 became the default package manager in Fedora 41, released in October 2024, and remains the default in later releases, including Fedora 44. On Fedora 41 and later, /usr/bin/dnf points to /usr/bin/dnf5, so the commands in this article continue to work as expected. However, using dnf5 explicitly is recommended going forward.
DNF5 is a ground-up rewrite of DNF in C++. It removes the Python dependency, processes metadata faster, uses less memory, and provides a cleaner, more consistent command-line interface.

Learning Linux commands from scratch? The 100+ Essential Linux Commands course on Pro TecMint covers package management, file handling, process control, and 90+ other commands, each explained with real output and hands-on exercises.

10. View Transaction History

dnf history info 12

net-tools-2.0-0.62.20160912git.el9.x86_64 : Basic networking tools
Repo : baseos
Matched from:
Filename : /usr/bin/netstat

Once you know these commands, everyday package management becomes simpler, safer, and easier to troubleshoot whether you’re installing a single package or maintaining a production Linux server.

dnf5 search nginx
dnf5 info nginx

dnf search all nginx

On Fedora 41+, /usr/bin/dnf is a symlink to /usr/bin/dnf5 for backward compatibility, so the commands in this article still work. However, if you’re using Fedora 41 or later, writing dnf5 explicitly is recommended.
sudo dnf install git curl wget vim

DNF5 includes config-manager as a built-in subcommand, so you don’t need a separate plugin for it.
sudo dnf clean metadata

One important distinction for 2025/2026 is DNF5. DNF5 is a complete C++ rewrite of DNF and is now the default package manager on Fedora 41 and later, including Fedora 44, the current release.
Prerequisites: You need a working RHEL 8/9/10, Rocky Linux, AlmaLinux, or Fedora system. Most commands require sudo or root privileges; commands that don’t are noted accordingly.
To add a repository:
sudo dnf clean all

To install a specific version instead, specify the complete package version:
DNF (Dandified YUM) has been the default package manager on Fedora since Fedora 22 (2015) and on RHEL since RHEL 8 (2019). It is used across RHEL 8/9/10, Rocky Linux, AlmaLinux, CentOS Stream, and Fedora. If you’re still typing yum on any of these systems, it is usually linked or aliased to DNF anyway.
sudo dnf check-update

dnf list –available

Know a sysadmin still using rpm -qa | grep to check installed packages? Share this dnf list --installed is cleaner.

8. Remove Unused Dependencies

One of DNF’s most useful features is the ability to undo a previous transaction using its ID.
sudo dnf5 config-manager setopt epel.enabled=1
sudo dnf5 config-manager setopt epel.enabled=0

Clean the Cache

Most people treat dnf as a drop-in replacement for yum and stop there. But that misses a lot of what makes DNF worth learning; automatic dependency resolution, transaction history with full undo support, module streams, and a plugin system that goes beyond what yum offered.
sudo dnf history undo 12

DNF is much more than a replacement for yum. It gives you better dependency resolution, transaction history, package rollback, repository management, package groups, and tools for finding and troubleshooting packages.
sudo dnf install -y nginx

2. Remove a Package

To check for broken dependencies across installed packages:
sudo dnf module reset nodejs
sudo dnf module enable nodejs:22
sudo dnf module install nodejs:22

dnf repolist –all

sudo dnf5 clean all

dnf provides /usr/bin/netstat
dnf provides */netstat

To view information about a package that is already installed:
Module streams have only basic support in DNF5 on Fedora. Fedora retired modularity in Fedora 39, so this is generally not relevant to current Fedora releases.

20. Check and Verify Installed Packages

You can also redo a transaction that was previously undone:
For example:
All examples below are tested on RHEL 9, Rocky Linux 9, and Fedora 44. A dedicated DNF5 section at the end of this article covers what changes on Fedora 41+.

Got a colleague moving from Ubuntu to RHEL? Share this DNF is one of the first things they’ll need to get comfortable with.

DNF vs YUM vs DNF5: Key Differences

Feature YUM DNF (dnf4) DNF5
Language Python Python C++
Dependency resolution Custom solver (error-prone) libsolv (accurate) libsolv (faster)
API Undocumented Fully documented Fully documented
Plugin support Python only Python + C Python + C + C++
Transaction history & undo No Yes Yes
Module streams No Yes (RHEL/Rocky) Basic (RHEL/Rocky)
Python dependency Yes Yes No
Memory usage High Medium Low
Default since RHEL 6/7 RHEL 8, Fedora 22 Fedora 41+
Current status Symlink to DNF Default on RHEL 8/9/10 Default on Fedora 41+

DNF5 on Fedora 41 and Later

What’s the first DNF task you’d trust yourself to automate on a production server, and what’s the one you’d always run manually? Drop it in the comments the commands are simple, but knowing where to draw the line matters.
sudo dnf update nginx

sudo dnf autoremove

dnf repolist

You might also like:
When a command is missing, and you need to find out which package provides it, use dnf provides:
sudo dnf check

sudo dnf config-manager –add-repo https://download.docker.com/linux/rhel/docker-ce.repo

sudo dnf update

ID | Command line | Date and time | Action(s) | Altered
——-+————————————-+——————+———–+——–
12 | install nginx | 2026-08-14 09:31 | Install | 3
11 | update | 2026-08-12 14:05 | Upgrade | 47
10 | remove vim-enhanced | 2026-08-10 11:22 | Removed | 1

DNF keeps a transaction history of package installations, updates, and removals. To view recent transactions:
# List available module streams
dnf module list nodejs

# Enable a specific stream
sudo dnf module enable nodejs:20

# Install the module
sudo dnf module install nodejs:20

sudo dnf reinstall nginx

sudo dnf install –enablerepo=crb curl
sudo dnf update –disablerepo=epel

DNF stores package metadata and downloaded RPMs in /var/cache/dnf. You can clean the cache if a repository is returning stale data or you’re running low on disk space:
Most commands are the same in DNF and DNF5. Here are the differences worth knowing.

If this article helped, with someone on your team.
TecMint Weekly Newsletter
Get the Learn Linux 7 Days Crash Course free when you join 34,000+ Linux professionals reading every Thursday.
Check your email for a magic link to get started.
Something went wrong. Please try again.

Similar Posts