Cheat Sheet

DNF Commands

dnf is the package manager on RHEL, Fedora, CentOS Stream, Rocky, and Alma, and on every current release yum is a symlink to it: same program, same options. These dnf commands cover installing, upgrading, searching, transaction history, groups, repositories, and the things that changed in dnf5, and every one of them works if you type yum instead.

Last updated September 11, 2026

Install and Remove

Every command on this page also works with in place of ; on current 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
Replace one package with another in a single transaction
Step back to the previous version the repos still carry
Drop the old kernels, keep the newest ones
Download the .rpm only, no install
Fetch into the cache now, install later

and are dead names. and have replaced them, and dnf5 removed the old spellings outright.

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
Match every package to what the repos carry now, downgrades included
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
Same command under its other name
Which installed package owns a file already on disk
List the files a package installs
What depends on a package

Missing Commands

Minimal RHEL installs and container images leave out tools people assume are always there. These are the ones gets asked about most.

Missing commandInstall
, ,
, ,
, ,
,

List Packages

CommandWhat it does
Every installed package
Check whether something is installed
What the enabled repos offer
Just the packages with a newer version waiting
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
Every transaction that touched one package
Reverse that one transaction
Reverse the most recent one
Undo every transaction after 42

Common Options

These work on any subcommand.

OptionWhat it does
, Answer yes to every prompt
Print the transaction, then answer no to it
Quiet: the result, not the progress
Use a disabled repo for this command only
Pin one command to one repo
, Skip packages matching a glob
Let dnf remove conflicting packages to satisfy the request
Accept an older version when the newest will not resolve
Drop the packages that cannot be resolved, do the rest
Skip signature checking (last resort, not a habit)
Pretend to be another release, mostly for
Work inside another root, such as a rescue chroot
One-off proxy for this command

A permanent proxy belongs in instead:

[main]
proxy=http://proxy.example.com:3128
proxy_username=user
proxy_password=secret

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, and its syntax changed in dnf5: see below. On RHEL itself, enable the CodeReady Builder repo through subscription-manager first, then install the epel-release RPM from the Fedora project.

Plugins

dnf-plugins-core ships the subcommands most people assume are built in. When one is missing, install the package that provides it rather than hunting for the name.

CommandWhat it does
config-manager, copr, download, reposync, builddep, needs-restarting
Install whatever package provides a missing subcommand
Enable a Fedora COPR repo
Download an RPM plus the dependencies you are missing
Install the build dependencies of a package or .spec file
Mirror a repo to disk
Find packages whose dependencies no longer resolve

On dnf5 these live in , which is why a fresh Fedora 41+ install answers .

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, and dnf5 has no command at all.

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: on dnf4, on dnf5.

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
Drop just the repo metadata, keep the packages
Rebuild the metadata cache now

frees space under , or on dnf5, and forces a fresh download next run. Installed packages are untouched. Reach for it when metadata is corrupt, after changing repositories, or when a mirror is serving stale data.

dnf5 Changes

Fedora 41 and later ship dnf5 as . It is mostly compatible, and these are the places it is not.

SymptomWhat to do instead
or
fails
fails
Cache is not where you left it, not
is goneModularity only ever shipped on RHEL 8 and 9
A subcommand is missingEarly dnf5 builds lacked and ; check
You just want the old one, then run

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
Remove config files toono equivalent
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.
  • There is no . Removing a package leaves your edited config files behind as ; find them with .
  • 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 FAQ

What is the difference between dnf and yum?

None, on anything still supported. DNF is Dandified YUM, a rewrite of yum on the libsolv dependency solver, and since RHEL 8 and Fedora 22 /usr/bin/yum has been a symlink to dnf: same code, same options, same output. Typing yum out of habit is harmless and old yum scripts keep running. The real yum survives only on RHEL and CentOS 7 and Amazon Linux 2, all past end of life. Fedora 41 and later ship dnf5, a second rewrite in C++, which is where the differences actually live.

Why do I get dnf: command not found?

Usually because the machine is not RHEL-family: Debian, Ubuntu, and Raspberry Pi OS use apt, Arch uses pacman, Alpine uses apk. On RHEL and CentOS 7 and on Amazon Linux 2 the command is yum, since dnf only became the default in RHEL 8; Amazon Linux 2023 has dnf. Minimal container images often ship microdnf instead, the same package manager with fewer features, and it is dnf5 under the hood on recent UBI images. If dnf runs for root but sudo dnf says command not found, /usr/bin is missing from secure_path in /etc/sudoers.

What is the dnf command to update all packages?

sudo dnf upgrade. dnf update is the same command under an older name, not a separate step, and there is no equivalent of apt update because dnf refreshes repository metadata itself once the cache expires; --refresh forces it early. check-update only reports, exiting 100 when updates exist, which is the exit code scripts should test for. dnf distro-sync is the heavier version: it moves every installed package to whatever the repos carry now, downgrading where needed, which is how you recover after adding or dropping a third-party repo.

How do I find which package provides a command?

dnf provides '*/dig' searches every enabled repo, installed or not, for a package shipping a file called dig in any directory; dnf whatprovides is the same command. Quote the pattern so the shell leaves it alone. A full path works too: dnf provides /etc/nginx/nginx.conf. The reverse lookups are in repoquery: dnf repoquery -l <pkg> lists what a package ships and dnf repoquery --whatrequires <pkg> shows what breaks if you remove it. For a file already on disk, rpm -qf /path answers instantly without touching the network.

How do I undo a dnf transaction?

Find the ID with dnf history, check it with dnf history info <id>, then sudo dnf history undo <id> reverses exactly that transaction: installs removed, removals reinstalled, upgrades downgraded. dnf history undo last takes the most recent one, and dnf history rollback <id> unwinds everything after that point instead. Undo needs the old versions to still exist in the repos, so it gets less reliable with age, fast on Fedora. Neither apt nor pacman has anything like it.

Related cheat sheets