Cheat Sheet

DNF Cheat Sheet

dnf is the package manager on RHEL, Fedora, CentOS Stream, Rocky, and Alma, and on every current release yum is simply another name for it: same code, same options. This dnf cheat sheet covers installing, upgrading, searching, transaction history, groups, and repositories, and every yum command works the same way.

Last updated September 5, 2026

Install and Remove

Every command on this page also works with in place of ; on modern systems they are the same program.

CommandWhat it does
Install a package and its dependencies
Install a local RPM with dependency resolution
Assume yes to the confirmation prompt (scripts)
Reinstall the current version
Remove a package, and by default the dependencies it pulled in
Remove leftover dependencies nothing needs
Step back to the previous version the repos still carry
Download the .rpm only, no install
Fetch into the cache now, install later

Update and Upgrade

looks, acts. There is no separate refresh step like ; dnf refreshes metadata by itself when the cache expires.

CommandWhat it does
List available updates; exit code 100 means there are some
Upgrade everything ( is the same command, older name)
Upgrade one package
Force fresh metadata before upgrading
Security fixes only
The security advisories that apply to this system
Say whether the updates call for a reboot

Search, Info and provides

is the feature worth memorizing: it tells you which package owns a file or ships a command, even for packages you have not installed.

CommandWhat it does
Search package names and summaries
Version, repo, size, description
Which package ships a command, wherever it lives
Which package owns a file
List the files a package installs
What depends on a package

List Packages

CommandWhat it does
Every installed package
Check whether something is installed
What the enabled repos offer
Packages you asked for, not dependencies
The classic rpm listing still works

History and Undo

Every transaction gets an ID you can inspect and reverse. This is the thing apt and pacman cannot do.

CommandWhat it does
Recent transactions with their IDs
Exactly what transaction 42 changed
Reverse that one transaction
Reverse the most recent one
Undo every transaction after 42

Groups

CommandWhat it does
Available package groups ( shows all of them)
What a group contains
Install the whole group
Remove it again

Repositories

CommandWhat it does
Enabled repositories
Including disabled ones
Enable a repo (CRB/PowerTools carries build dependencies on RHEL clones)
Disable one
Add a repo from a .repo file URL
EPEL on Rocky, Alma, and CentOS Stream: the big pool of extra packages

comes from dnf-plugins-core. On Fedora 41+ (dnf5) the syntax changed: and . On RHEL itself, enable the CodeReady Builder repo through subscription-manager first, then install the epel-release RPM from the Fedora project.

Modules

RHEL 8 and 9 ship some packages (nodejs, postgresql, php) as module streams with selectable major versions. Fedora and RHEL 10 dropped the mechanism.

CommandWhat it does
Available streams and which is enabled
Pick a stream
Enable and install in one go
Back to the default stream

Version Lock

Needs the plugin: .

CommandWhat it does
Hold the installed version through upgrades
Locked packages
Release one
Release everything

Cache and Clean

CommandWhat it does
Drop cached metadata and downloaded packages
Rebuild the metadata cache now

dnf, apt and pacman

The same tasks on Debian and Ubuntu are in the apt cheat sheet, and on Arch in the pacman cheat sheet.

Taskdnfaptpacman
Refresh and upgrade
Install
Remove with dependencies
Search
Who owns a file
List installed
Undo a transactionno equivalentno equivalent

Gotchas

  • also removes the dependencies that came with the package ( defaults to on), where apt needs a separate . Check the transaction summary before confirming.
  • fails once the old package versions have left the repositories, which happens fast on Fedora. Undo soon or not at all.
  • 's exit code 100 is a feature, not an error: scripts should treat 0 as "nothing to do", 100 as "updates available", 1 as a real failure.
  • Kernel updates install side by side rather than replacing, so can fill up; dnf keeps the newest three by default ( in ).

DNF & YUM Cheat Sheet FAQ

Is yum the same as dnf?
On RHEL 8 and later, Fedora 22 and later, and every current Rocky, Alma, and CentOS Stream release, yum is a symlink to dnf: same code, same options, same output. Old scripts and muscle memory that type yum keep working. The original yum only survives on RHEL and CentOS 7, which are end of life, so new scripts and docs should say dnf.
What is the difference between dnf check-update and dnf upgrade?
check-update only reports: it lists packages with newer versions and exits with code 100 when updates exist, which makes it useful in scripts and monitoring. upgrade actually installs them. dnf update is not a third behaviour, just an older alias for upgrade. There is no separate refresh step like apt update; dnf fetches fresh metadata on its own when the cache expires, or immediately with --refresh.
How do I find which package provides a command or file?
dnf provides '*/htpasswd' searches every repository, installed or not, for a package shipping a file named htpasswd in any directory, and dnf provides /etc/nginx/nginx.conf works with a full path. It is the answer to 'command not found' on a minimal install. The reverse directions: dnf repoquery -l <pkg> lists what a package ships, and dnf repoquery --whatrequires <pkg> shows what depends on it.
How do I undo a dnf transaction?
Find the transaction ID with dnf history, inspect it with dnf history info <id>, then sudo dnf history undo <id> reverses exactly that transaction: installs are removed, removals reinstalled, upgrades downgraded. dnf history rollback <id> undoes everything after that point instead. Undo needs the old package versions to still exist in the repositories, so it is most reliable soon after the transaction.
What does dnf clean all do and when should I run it?
It deletes dnf's cached repository metadata and downloaded packages under /var/cache/dnf (or /var/cache/libdnf5 on dnf5 systems), freeing disk space and forcing a fresh download on the next run. Use it when metadata is corrupt, after changing repositories, or when a mirror serves stale data, then run dnf makecache to rebuild the cache right away. Installed packages are untouched.

Related cheat sheets