dnf Package Management - Modern Tool for Fedora and RHEL-Based Systems

dnf Package Management - Modern Tool for Fedora and RHEL-Based Systems

What You'll Learn

  • Core dnf operations for Fedora and RHEL-based systems
  • Why dnf replaced yum and what changed
  • How to use module streams — a dnf-specific feature not available in yum

Quick Summary

  • Install: sudo dnf install [package]
  • Update all: sudo dnf update
  • Remove: sudo dnf remove [package]
  • Rollback: sudo dnf history undo [id]

What Is dnf?

dnf (Dandified YUM) is the successor to yum, the standard package manager since Fedora 22 and RHEL 8 / CentOS 8. It resolves dependencies faster and uses less memory than yum.

Supported distributions: Fedora / RHEL 8+ / CentOS 8+ / AlmaLinux / Rocky Linux / Oracle Linux

Not for Ubuntu/Debian

Ubuntu and Debian-based systems use apt, not dnf. dnf is exclusive to RPM-based distributions. See the apt/yum basics article

Installing and Removing Packages

The most fundamental dnf operations.

Install a package

sudo dnf install vim

Install multiple packages at once:

sudo dnf install vim git curl

Install from a local RPM file:

sudo dnf install ./package.rpm

Remove a package

sudo dnf remove vim

remove also removes packages that depend on the target. Use --no-autoremove to remove only the specified package without cascading.

Remove orphaned dependencies:

sudo dnf autoremove

Updating Packages

Regular updates are essential for security.

Update all packages

sudo dnf update

dnf upgrade is an alias for dnf update — both behave identically.

Update a specific package

sudo dnf update vim

Apply only security updates

sudo dnf update --security

Check what would be updated (without applying)

dnf check-update

Searching and Inspecting Packages

How to investigate packages before installing.

Search by keyword

dnf search nginx

Search across both package names and descriptions:

dnf search all nginx

View detailed package information

dnf info nginx

Shows version, architecture, size, repository, and description.

List installed packages

dnf list installed

List all available packages (including not yet installed):

dnf list available

Check the status of a specific package:

dnf list vim

Find which package provides a command

dnf provides /usr/bin/vim

Managing Package Groups

Groups let you install related packages together.

List available groups

dnf group list

Install a group

sudo dnf group install "Development Tools"

View group contents

dnf group info "Development Tools"

Managing Repositories

How to manage package sources.

List enabled repositories

dnf repolist

Include disabled repositories:

dnf repolist --all

Add the EPEL repository (RHEL/CentOS)

sudo dnf install epel-release

Temporarily disable a repository for one install

sudo dnf install [package] --disablerepo=epel

Managing the Package Cache

Keep disk usage in check by managing the download cache.

sudo dnf clean all

Refresh the package list without discarding the cache:

sudo dnf makecache

History and Rollback

One of dnf's most powerful features: a full operation history with rollback support.

View operation history

dnf history

Inspect a specific operation

dnf history info 5

Undo an operation

sudo dnf history undo 5

If a system update causes issues, dnf history undo restores the previous state — invaluable in production environments.

Module Streams

Module streams are a dnf-specific feature that lets you install and switch between multiple versions of the same software.

List available modules

dnf module list

View module details

dnf module info nodejs

Enable a specific version and install

sudo dnf module enable nodejs:18
sudo dnf install nodejs

Switch to a different stream

sudo dnf module reset nodejs
sudo dnf module enable nodejs:20
sudo dnf distro-sync

After switching module streams, always run dnf distro-sync to realign package versions with the new stream.

dnf vs yum

Operation yum dnf
Install yum install dnf install
Remove yum remove dnf remove
Update yum update dnf update
Search yum search dnf search
Remove orphans yum autoremove dnf autoremove
Module management Not supported dnf module
Rollback Limited dnf history undo

On RHEL 8+, the yum command is a compatibility shim that calls dnf under the hood. The commands are interchangeable, but dnf offers more features and better performance.

Next Reading