Skip to content

DNF (Dandified YUM) — Package Management in RHEL, Rocky, AlmaLinux, and Fedora

DNF (Dandified YUM) is the modern package manager used by Fedora, Red Hat Enterprise Linux (RHEL), Rocky Linux, AlmaLinux, and other RPM-based distributions. It simplifies installing, updating, removing, and managing software packages while providing better dependency resolution, improved performance, and enhanced security compared to its predecessor, YUM.


Learning Path

Linux Mastery → Module 7: Package Management → Lesson 2

Difficulty: Beginner → Intermediate

Reading Time: 60 Minutes

Course Progress

Course: Linux Mastery

Module: Package Management

Lesson: 2 of 10


What You'll Learn

After completing this lesson, you'll be able to:

  • Understand DNF
  • Install and remove software packages
  • Search package repositories
  • Update installed software
  • Manage dependencies
  • View package information
  • Clean package cache
  • Apply package management in production

Prerequisites

Complete:

  • Module 1 – Linux Fundamentals
  • Module 2 – Linux Command Line Essentials
  • Module 3 – Text Processing
  • Module 4 – File Management and Permissions
  • Module 5 – Users and Groups
  • Module 6 – Process Management
  • Module 7 Lesson 1 – APT

Why Learn DNF?

Imagine you're managing:

  • Red Hat Enterprise Linux servers
  • Rocky Linux production systems
  • AlmaLinux cloud instances
  • Fedora developer workstations

You need to:

  • Install Docker
  • Update Kubernetes tools
  • Patch security vulnerabilities
  • Remove unused software

DNF makes these tasks simple and reliable.


What is DNF?

DNF stands for:

Dandified YUM

It is the default package manager for modern RPM-based Linux distributions.

DNF works with:

.rpm

packages and automatically:

  • Resolves dependencies
  • Downloads packages
  • Verifies package signatures
  • Installs software
  • Manages updates

Package Management Workflow

DNF Command
Software Repository
Download Packages
Resolve Dependencies
Install Software
Ready to Use

What is an RPM Package?

An RPM package contains:

  • Executable binaries
  • Libraries
  • Configuration files
  • Documentation
  • Metadata

Example:

nginx-1.24.0-1.el9.x86_64.rpm

Refresh Repository Metadata

Before installing packages:

sudo dnf check-update

This checks repositories for available updates and refreshes package metadata if needed.


Install a Package

Example:

sudo dnf install nginx

Install multiple packages.

sudo dnf install git curl vim

DNF automatically resolves dependencies.


Upgrade Installed Packages

Upgrade all installed packages.

sudo dnf upgrade

or

sudo dnf update

Both commands are equivalent in modern DNF.


Upgrade a Specific Package

sudo dnf upgrade nginx

Remove a Package

sudo dnf remove nginx

Unused dependencies are removed when appropriate.


Search for Packages

dnf search nginx

Example:

nginx

nginx-core

nginx-filesystem

View Package Information

dnf info nginx

Displays:

  • Version
  • Repository
  • Size
  • Description
  • Architecture

List Installed Packages

dnf list installed

Search for a package.

dnf list installed | grep nginx

Check Available Updates

dnf check-update

Displays packages that have newer versions available.


Display Package Repositories

dnf repolist

Example:

AppStream

BaseOS

Extras

Clean Package Cache

Remove cached packages.

sudo dnf clean packages

Remove all cached metadata and packages.

sudo dnf clean all

Rebuild the cache.

sudo dnf makecache

Download a Package Without Installing

sudo dnf download nginx

Note

The dnf download command is provided by the dnf-plugins-core package on many distributions.


View Package History

Display transaction history.

dnf history

Example:

ID

Command

Date

Action

View details of a transaction.

dnf history info <ID>

Undo a Transaction

sudo dnf history undo <ID>

This attempts to reverse a previous package transaction.


Common Commands

Install package.

sudo dnf install nginx

Upgrade packages.

sudo dnf upgrade

Remove package.

sudo dnf remove nginx

Search package.

dnf search nginx

Display package information.

dnf info nginx

List repositories.

dnf repolist

Real Production Examples

Install Git.

sudo dnf install git

Install Docker.

sudo dnf install docker

Update production server.

sudo dnf upgrade

Install Kubernetes CLI.

sudo dnf install kubectl

Production Perspective

DNF is widely used for:

  • Red Hat Enterprise Linux
  • Rocky Linux
  • AlmaLinux
  • Fedora
  • Cloud Virtual Machines
  • Kubernetes Nodes
  • Enterprise Servers
  • Production Infrastructure

Keeping packages updated is essential for security and stability.


Hands-on Lab

Task 1

List enabled repositories.

dnf repolist

Task 2

Search for Git.

dnf search git

Task 3

View package details.

dnf info git

Task 4

Check for updates.

sudo dnf check-update

Task 5

Install Git (if not already installed).

sudo dnf install git

Task 6

Verify installation.

git --version

Task 7

View package history.

dnf history

Task 8

Clean the package cache.

sudo dnf clean all

Command Deep Dive

Command Purpose Production Example
dnf install Install packages Software deployment
dnf upgrade Upgrade installed packages Security patching
dnf remove Remove software Cleanup
dnf search Search repositories Package discovery
dnf info Display package information Verification
dnf repolist List repositories Repository management
dnf history View transaction history Auditing
dnf clean all Clear cache Maintenance

DNF vs APT

Feature APT DNF
Package Format .deb .rpm
Primary Distributions Debian, Ubuntu RHEL, Rocky, AlmaLinux, Fedora
Install apt install dnf install
Update Metadata apt update dnf check-update / dnf makecache
Upgrade apt upgrade dnf upgrade
Package Info apt show dnf info

Production Troubleshooting Scenario

Scenario

A system administrator attempts to install NGINX.

sudo dnf install nginx

Error:

No match for argument: nginx

Investigation:

dnf repolist

The required repository is disabled.

After enabling the correct repository:

sudo dnf makecache

sudo dnf install nginx

The package installs successfully.


Best Practices

  • Keep repositories enabled and synchronized.
  • Apply security updates regularly.
  • Review package changes before upgrading production systems.
  • Remove unused software.
  • Clean the package cache periodically.
  • Use only trusted repositories.

Common Mistakes

❌ Installing packages from untrusted repositories.

✅ Avoid this mistake: installing packages from untrusted repositories.


❌ Ignoring available security updates.

✅ Always review available security updates.


❌ Cleaning metadata without rebuilding the cache when required.

✅ Avoid this mistake: cleaning metadata without rebuilding the cache when required.


❌ Upgrading production servers without testing critical applications.

✅ Avoid this mistake: upgrading production servers without testing critical applications.


Interview Questions

Beginner

  1. What does DNF stand for?
  2. Which Linux distributions use DNF?
  3. Which command installs a package?
  4. How do you search for a package?

Intermediate

  1. What is the difference between dnf upgrade and dnf check-update?
  2. How do you list enabled repositories?
  3. How do you remove a package?
  4. What is the purpose of dnf history?

Architect Level

  1. How would you manage package updates across hundreds of RHEL servers?
  2. Why should production systems use trusted repositories?
  3. How would you implement a package update strategy that minimizes downtime?

Summary

In this lesson, you learned:

  • DNF package management
  • Package installation
  • Package upgrades
  • Repository management
  • Package history
  • Package cleanup
  • Production best practices

DNF is the modern package manager for RPM-based Linux distributions. It simplifies software management by automatically resolving dependencies, managing repositories, and tracking package transactions. Mastering DNF is essential for administering Red Hat Enterprise Linux, Rocky Linux, AlmaLinux, and Fedora systems.


Key Takeaways

  • DNF is the default package manager for modern RPM-based distributions.
  • Use dnf install to install software.
  • Use dnf upgrade to apply updates.
  • Use dnf search and dnf info to explore packages.
  • Use dnf history to review package transactions.
  • Use trusted repositories and apply updates regularly.

What's Next?

YUM (Yellowdog Updater Modified) — Package Management for Legacy RHEL Systems

You'll explore:

  • What YUM is
  • How YUM differs from DNF
  • Installing and updating packages
  • Repository management
  • Legacy RHEL systems
  • Migration from YUM to DNF
  • Production package management for older enterprise Linux systems