Skip to content

dnf Package Manager in Fedora and Redhat


dnf is the repository-aware, dependency-resolving tool you’ll use for nearly everything on Fedora and RHEL-family systems — the direct counterpart to apt, calling down into rpm internally the same way apt calls into dpkg. This chapter covers it fully, including one genuinely standout feature that apt doesn’t offer nearly as cleanly: transaction history with real rollback.

Installing With Dependency Resolution

sudo dnf install nginx
Dependencies resolved.
================================================================
 Package    Arch    Version         Repository       Size
================================================================
Installing:
 nginx      x86_64  1:1.24.0-1.fc40  fedora           580 k
Installing dependencies:
 nginx-core x86_64  1:1.24.0-1.fc40  fedora           620 k

Transaction Summary
================================================================
Install  2 Packages

Is this ok [y/N]:

Same underlying idea as apt install — full dependency resolution, a clear summary before anything actually changes, a confirmation prompt worth reading rather than reflexively accepting.

Removing And Cleaning Up Dependencies

sudo dnf remove nginx

Recall from the last chapter that rpm doesn’t have Debian’s separate remove/purge distinction — configuration handling instead happens through .rpmsave/.rpmnew, and dnf remove follows that same underlying model.

sudo dnf autoremove

Exactly the same concept as apt autoremove — packages that were pulled in automatically as dependencies, and are no longer needed by anything currently installed, get identified and offered for removal.

Searching And Inspecting

dnf search nginx
dnf info nginx

Directly equivalent to apt search/apt show — searching without knowing an exact package name, and full metadata before committing to an install.

dnf list installed
dnf check-update

Lists everything currently installed, and checks what has updates available without actually applying them — the dnf equivalent of apt list --installed/apt list --upgradable.

Updating: No upgrade/full-upgrade Split

sudo dnf update

Worth noting explicitly since it’s a genuine difference from the Debian side: dnf doesn’t split this into a conservative and a more thorough mode the way apt upgrade/apt full-upgrade do. dnf update will resolve whatever dependency changes are genuinely needed, including removing a package if that’s required to satisfy an upgrade — closer in behavior to apt full-upgrade than to the more cautious apt upgrade. (dnf upgrade is also accepted as an alias for the same operation — the two names refer to identical behavior here, unlike on the Debian side where they mean genuinely different things.)

The Standout Feature: dnf history

This is worth its own dedicated attention, since it’s a real, practical advantage over the Debian-side tooling covered so far. dnf records every transaction — every install, remove, and update — as a numbered entry you can inspect and, critically, undo.

dnf history
ID  | Command line          | Date and time    | Action(s) | Altered
------------------------------------------------------------------
 12 | install nginx         | 2026-01-15 09:14  | Install   |    2
 11 | remove old-package     | 2026-01-14 16:02  | Removed   |    1
dnf history info 12

Full detail on exactly what that specific transaction did — every package installed, removed, or upgraded as part of it.

sudo dnf history undo 12

This genuinely reverses that entire transaction — if it installed two packages, undo removes exactly those two packages, cleanly, without needing to remember or manually reconstruct what happened. This is a meaningfully more complete rollback mechanism than anything covered on the Debian side, where reversing a multi-package operation generally means manually working out what to remove yourself.

Repository Configuration: /etc/yum.repos.d/

ls /etc/yum.repos.d/
cat /etc/yum.repos.d/fedora.repo
[fedora]
name=Fedora $releasever - $basearch
baseurl=https://download.example.org/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch

Each .repo file defines one or more repositories in this [section]-style format — a name, the actual URL, whether it’s currently enabled, and the trust settings. gpgcheck=1 enables signature verification for this repository — matching the trust discussion from earlier in this section — and gpgkey points at the key used to verify it.

dnf repolist

Shows every currently enabled repository — a quick way to confirm exactly which sources dnf is actually pulling from.

Warning

Exactly the same caution as adding a third-party apt repository: a .repo file with gpgcheck=0 accepts packages with no signature verification at all. Never disable this as a shortcut past an error — it removes the one check confirming a package genuinely came from who it claims to, before its maintainer scripts run as root on your system.

A Note On yum

You’ll frequently see yum install in older documentation, scripts, and habits — yum was dnf’s direct predecessor, and on most current Fedora and RHEL-family systems, yum still works as a compatibility alias pointing straight at dnf. There’s no real reason to prefer yum on a modern system, but recognizing it as functionally the same tool under an older name avoids unnecessary confusion when it shows up in existing material.

Clearing The Local Cache

sudo dnf clean all

Removes cached package metadata and downloaded packages — genuinely useful if the cache has become large, or if metadata seems stale in a way a plain dnf check-update didn’t resolve. A later chapter in this section maps out exactly where this cache (and everything else dnf/rpm touch) actually lives on disk.

What’s Next

You now have full command of the Fedora/RHEL package ecosystem, low-level and high-level together, symmetric with everything covered on the Debian side. The next chapter mirrors the earlier .deb walkthrough directly — building a real .rpm package from scratch, this time packaging a Python script instead of a compiled C program.

Last updated on