Install and Remove
Every command on this page also works with in place of ; on current systems they are the same program.
| Command | What 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.
| Command | What 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.
| Command | What 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 command | Install |
|---|---|
| , , | |
| , , | |
| , , | |
| , | |
List Packages
| Command | What 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.
| Command | What 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.
| Option | What 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=secretGroups
| Command | What it does |
|---|---|
| Available package groups ( shows all of them) | |
| What a group contains | |
| Install the whole group | |
| Remove it again |
Repositories
| Command | What 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.
| Command | What 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.
| Command | What 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.
| Command | What it does |
|---|---|
| Hold the installed version through upgrades | |
| Locked packages | |
| Release one | |
| Release everything |
Cache and Clean
| Command | What 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.
| Symptom | What to do instead |
|---|---|
| or | |
| fails | |
| fails | |
| Cache is not where you left it | , not |
| is gone | Modularity only ever shipped on RHEL 8 and 9 |
| A subcommand is missing | Early 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.
| Task | dnf | apt | pacman |
|---|---|---|---|
| Refresh and upgrade | |||
| Install | |||
| Remove with dependencies | |||
| Remove config files too | no equivalent | ||
| Search | |||
| Who owns a file | |||
| List installed | |||
| Undo a transaction | no equivalent | no 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 ).