Community Tutorials RHEL / Rocky / AlmaLinux DNF Package Manager Basics on RHEL 9
DNF Package Manager Basics on RHEL 9
RHEL / ROCKY / ALMALINUX

DNF Package Manager Basics on RHEL 9

SKYLINE Knowledge Base
Photo by imattsmart on Unsplash

A field-tested, step-by-step guide. DNF Package Manager Basics on RHEL 9 — prerequisites, the actual commands, verification, and links to related RHEL / Rocky / AlmaLinux topics.

dnf is the package manager on every RHEL-family distro from RHEL 8 onward — Rocky, Alma, Oracle Linux, Fedora. It replaced yum, though yum still exists as a symlink for muscle-memory. This guide covers the commands you will run weekly.

Prerequisites

  • Rocky 9 / Alma 9 / RHEL 9 with sudo.
  • Outbound HTTPS reachable for the configured mirrors.

Step 1: Refresh metadata and list updates

sudo dnf check-update              # exit code 100 = updates available
sudo dnf list --installed | wc -l
sudo dnf list --upgrades

Step 2: Install, remove, search

sudo dnf install -y vim git tmux
sudo dnf remove  -y unwanted-pkg
dnf search redis                  # search names + summaries
dnf info redis                    # detailed metadata
dnf provides /usr/bin/openssl     # which package owns this file?

Step 3: Upgrades

sudo dnf upgrade -y               # security + bugfix updates
sudo dnf upgrade --security -y    # security only
sudo dnf upgrade --refresh -y     # force a metadata refresh first

After kernel updates:

sudo dnf needs-restarting -r      # 0 = no reboot; 1 = reboot needed

Step 4: Repositories

dnf repolist                      # enabled repos
dnf repolist --all                # all configured repos (incl. disabled)
sudo dnf config-manager --enable crb       # enable CodeReady Builder
sudo dnf install -y epel-release           # add EPEL
sudo dnf config-manager --add-repo https://example.com/repo.repo

config-manager is in dnf-plugins-core on RHEL 9 — install it if missing.

Step 5: Modules and streams (AppStream)

RHEL 9 ships PHP, Node, Python, etc. as modules with selectable streams:

dnf module list nodejs
sudo dnf module enable -y nodejs:20
sudo dnf module install -y nodejs:20/common
sudo dnf module reset nodejs                 # back to default stream

Step 6: Clean and lock

Reclaim disk used by the package cache:

sudo dnf clean all
sudo dnf clean dbcache

Lock a package at a known version (useful for production stability):

sudo dnf install -y python3-dnf-plugin-versionlock
sudo dnf versionlock add postgresql-server
sudo dnf versionlock list

Verify

sudo dnf history list | head      # last transactions
sudo dnf history info 5           # what changed in transaction 5
sudo dnf history undo 5           # revert that transaction (carefully)

Conclusion

dnf is the same toolbox as apt on Debian/Ubuntu, just spelled differently. Learn check-update, upgrade, install, remove, info, provides, history, and you are 95 percent of the way to RHEL operations.

Next steps

SKYLINE Engineering

@skyline

The engineering team at SKYLINE Industrial Solutions. We publish field-tested guides drawn from real KSA and GCC deployments.

See author profile
SKYLINE engineering services

Need this implemented for you?

Reading is free — building it right takes a team. SKYLINE engineers ship RHEL / Rocky / AlmaLinux for Aramco vendors, banks, hospitals and government agencies across Saudi Arabia. Talk to us before you start.

Aramco Approved Contractor ISO 9001 · ISO 27001 SAMA CSF aligned NCA ECC ready 247+ KSA clients

Comments

0 total · 0 threads
Be the first to leave a comment.