dnf and rpm
Package management on Fedora, RHEL, Rocky and Alma: rpm queries, dnf on top, where repo files live now, undoing a transaction, and what became of modules.
dnf and rpm
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- rpm installs and queries single packages and owns the database; dnf resolves dependencies, talks to repositories, and records every transaction. Fedora 41 and later run DNF5 (dnf is a symlink to dnf5); RHEL 10 still documents the classic DNF tool.
- rpm -qa lists installed packages, rpm -qf FILE finds the owner of a file, rpm -ql PKG lists a package's files, rpm -V checks installed files against the database.
- Repository definitions are .repo files. /etc/yum.repos.d is still read, but Fedora 45 ships its own repo files in /usr/share/dnf5/repos.d and leaves /etc/yum.repos.d empty.
- dnf history list shows every transaction; dnf history undo ID reverses one and rollback ID reverses everything after it. Undoing large upgrades can fail if the old versions are no longer in a repository.
- Modularity (AppStream module streams) is deprecated: RHEL 10 ships its Application Streams as ordinary packages and warns when the module command is used.
The same two layers, Red Hat style
The Red Hat family splits package management the same way Debian does in the apt lesson. rpm is the low layer: it installs a single .rpm, records its files and metadata, verifies them, and removes them. dnf is the high layer: it reads repositories, resolves dependencies with the libsolv solver, downloads, and drives rpm. On older systems the high layer was called yum, and the name lives on as an alias.
One version note before any commands. Fedora 41 replaced the classic DNF with DNF5, a rewrite. In the official Fedora 45 container image I downloaded, /usr/bin/dnf and /usr/bin/yum are both symlinks to dnf5. RHEL 10’s documentation still describes “the DNF tool”, the older line that RHEL 8 and 9 use. Most everyday commands are the same; a few differ, noted below.
The everyday commands
Written from the documentation and the video, not run here:
sudo dnf check-update # what has updates (refreshes metadata if stale)
sudo dnf upgrade # upgrade everything
sudo dnf install nginx
sudo dnf remove nginx # also removes dependencies nothing else needs
dnf search nginx
dnf info nginx
dnf provides /usr/bin/dig # which package would supply this file
Unlike apt, there is no separate update step: dnf refreshes repository metadata itself when its cache expires. dnf provides is the equivalent of searching Debian’s file lists and is handy when a command is missing.
Querying with rpm
rpm(8) offers query flags that answer the same questions as dpkg -S and -L: -qa to “query all installed packages”, -qf FILE to “query package owning installed FILE”, -ql to “list files in package”, and -V to verify installed files against “the package metadata stored in the rpm database”, which flags changed configs and tampered binaries alike.
The database itself is an SQLite file, /usr/lib/sysimage/rpm/rpmdb.sqlite, with /var/lib/rpm a symlink to that directory. Because it is SQLite, I could open the Fedora 45 image’s copy read-only with the Mac’s sqlite3. The rpm tool would normally do this for you:
$ sqlite3 -readonly rpmdb.sqlite "select count(*) from Packages;"
149
$ sqlite3 -readonly rpmdb.sqlite "select key from Name where hnum=(select hnum from Basenames where key='ls');"
coreutils
$ sqlite3 -readonly rpmdb.sqlite "select count(*) from Basenames b join Name n on b.hnum=n.hnum where n.key='coreutils';"
302
149 packages installed, ls belongs to coreutils, and coreutils owns 302 file names. That is what rpm -qa | wc -l, rpm -qf /usr/bin/ls and rpm -ql coreutils report, modulo how directories are counted. The same database also holds dependency tables. For dnf5 it lists requirements such as libc.so.6(GLIBC_2.34)(64bit) and librpm.so.10()(64bit): RPM records library dependencies by soname and symbol version automatically at build time.
Where repositories are defined
A repository is a .repo file in INI format. The DNF5 configuration reference gives the default search path as /etc/yum.repos.d, /etc/distro.repos.d and /usr/share/dnf5/repos.d. Fedora 45 now uses the last one for its own repositories: in the image, /etc/yum.repos.d/ is empty and fedora.repo lives in /usr/share/dnf5/repos.d/. Its main section reads:
[fedora]
name=Fedora $releasever - $basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch
enabled=1
gpgcheck=1
gpgkey=file:///usr/share/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
gpgcheck=1 means every package’s signature is checked against the key file named in gpgkey. The metalink asks Fedora’s mirror service for a nearby mirror plus checksums of the metadata, so any mirror can be used safely. Your own repositories still go in /etc/yum.repos.d/, and RHEL 10 still keeps its repository files there. DNF5’s config-manager no longer edits existing repo files; per its changes document, “drop-in override files are created instead”, in /etc/dnf/repos.override.d/.
Transaction history and undo
Every dnf transaction is recorded. This is one of the Red Hat family’s best features:
dnf history list # DNF5 requires the subcommand; classic dnf accepts plain 'dnf history'
dnf history info 42
sudo dnf history undo 42
sudo dnf history rollback 40
The DNF5 docs define undo as “Revert all actions from the specified transaction” and rollback as “Undo all transactions performed after the specified transaction”. Undo works best for installs and removals. Reversing an upgrade means downgrading, which needs the old package versions to still be available from a repository, and they often are not once updates have superseded them.
Modules and Application Streams
RHEL 8 introduced modularity: module streams such as nodejs:18 or php:8.2 that let one release offer several versions of a language or database, enabled with dnf module enable. It confused many administrators and is on its way out. Red Hat’s RHEL 10 documentation says modularity is deprecated, that the dnf module command shows a deprecation warning, and that RHEL 10 provides its Application Streams, the alternative versions, as normal RPM packages you install with dnf install. Fedora stopped shipping modular repositories earlier. You will still meet module streams on RHEL 8 and 9 for years.
About the video
The embed is Red Hat’s “Using dnf to install, update, remove, and manage software packages on Linux | Into the Terminal 128”, a December 2024 stream, clipped to its first 26.5 minutes: searching, installing, upgrading specific packages, removing, listing, finding what provides a command, history, undo and history info. It is on RHEL with the classic DNF, so it predates DNF5’s required history list subcommand and Fedora’s new repo directory. The rest of the stream, on adding repositories and EPEL, is linked from the next lesson. I judged it from its chapters and description, and English from its uploaded English captions. Learn Linux TV’s dnf crash course and Red Hat’s rpm stream are in deeper.
What was run: inspecting the downloaded Fedora 45 image on a Mac, including read-only sqlite3 queries of its rpm database and reading its repo files. Command behaviour is from rpm(8) and the DNF5 documentation (dnf5.conf(5), the history command and the DNF4-to-DNF5 changes page); the RHEL 10 modularity and DNF statements are from Red Hat’s RHEL 10 documentation as reported in search results, since docs.redhat.com refused automated fetches. Checked 2026-11-28.
Check yourself
Which rpm command tells you what package installed /usr/bin/ls, and which lists everything that package installed?
rpm -qf /usr/bin/ls shows the owner (coreutils), and rpm -ql coreutils lists its files.
You installed a package that pulled in fifteen dependencies and want all of it gone. What is the cleanest way?
Find the transaction with dnf history list and run dnf history undo with its ID, which reverses exactly that transaction including the dependencies it added.
On a Fedora 45 machine, ls /etc/yum.repos.d is empty, yet dnf can install packages. Where are the repositories defined?
In /usr/share/dnf5/repos.d, one of the directories in DNF5's default reposdir list, alongside /etc/yum.repos.d and /etc/distro.repos.d.
A runbook says dnf module enable php:8.2 for RHEL 10. Why might that not work as written?
Modularity is deprecated in RHEL 10 and Red Hat does not ship Application Streams as modules there. Alternative versions are ordinary packages installed with dnf install.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.