Skip to main content
RunBook Academy

LinuxXI · Package Managementdnf and rpm

dnf and rpm — RHEL-family package management

Foundation⏱ ~12 minbashdnfrpmyum

What you'll learn

  • Update, upgrade, install, and remove packages with dnf
  • Query installed packages and their contents
  • Configure repositories and GPG keys safely
  • Distinguish dnf from rpm and use each appropriately

Prerequisites

Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09

Not yet marked complete on this device.

dnf is the high-level interface to the RPM package system on modern RHEL-family distributions. rpm is the low-level tool. RHEL 8 deprecated yum in favour of dnf; on RHEL 9 and later, dnf is the only high-level tool.

The day-to-day commands

Configuration changednf update + upgrade
$ sudo dnf check-update; sudo dnf upgrade -y
...

Illustrative output

Read-only / Safednf search / info
$ dnf search web-server | head; dnf info nginx
...

Illustrative output

Configuration changednf install / remove
$ sudo dnf install nginx; sudo dnf remove nginx
...

Illustrative output

Module streams

RHEL-family packages use modules for multiple versions:

Configuration changednf modules
$ dnf module list; dnf module enable nodejs:18; sudo dnf install @nodejs:18
...

Illustrative output

Querying installed packages

Read-only / Saferpm queries
$ rpm -qa 'nginx*'; rpm -ql nginx; rpm -qf /etc/nginx/nginx.conf
...

Illustrative output

Read-only / Saferpm -V
$ rpm -V nginx 2>&1 | head
S.5....T.  c /etc/nginx/nginx.conf\n..?

Illustrative output

Configuring repositories

Read-only / Safeyum.repos.d
$ ls /etc/yum.repos.d/; cat /etc/yum.repos.d/rocky.repo 2>/dev/null | head -20
...

Illustrative output

A typical local-mirror.repo file has the following structure. The bracketed section name is the repository identifier, the baseurl points to the package source, enabled activates the repository, gpgcheck enforces signature verification, and gpgkey references the GPG key file or URL. The optional priority field (covered earlier in this lesson) controls preference.

dnf history and rollback

Configuration changednf history
$ dnf history list; sudo dnf history undo <id>
...

Illustrative output

Module streams and version pinning

Read-only / Safemodule stream info
$ dnf module list nginx; dnf module info nginx:1.24
...

Illustrative output

Knowledge check

Knowledge check · 3 questions

  1. Q1. What does rpm -V nginx report?

  2. Q2. gpgcheck=1 with a trusted gpgkey is what stops a compromised mirror from installing arbitrary binaries.

  3. Q3. Which of the following are correct dnf practices? Select all that apply.

Passing score: 75%. Answers are checked in this browser.