DNF and RPM
Quick answer
RHEL and Fedora use RPM packages, with DNF coordinating repository and dependency operations. RPM queries describe installed packages; DNF can also query repositories.
Prepare the practice environment
Use an ordinary user in a disposable VM of the distribution named in the example. For Debian examples use python3 lab-fixtures/packages/setup.py from the extracted package root, enter the printed directory and check pwd; alternatively create a private directory with mktemp -d. Use a fresh directory per example, export LC_ALL=C and Bash with set -o pipefail. Do not use sudo. Keep -s and --no-download on every APT simulation. Skip missing tools; do not install them merely to run an example. On Alpine the simple query also works in a compatible sh. Outputs vary by installed versions and repository state. Stop on unexpected failure.
How it works
Use RHEL 9 as the secondary teaching environment (DNF 4 family); Fedora may use DNF 5 and some subcommands differ. rpm -q NAME queries an installed package; rpm -ql NAME lists its recorded files; rpm -qf PATH finds an owner. DNF can resolve dependency graphs for install and upgrade. dnf --cacheonly list --installed NAME uses local state and cached metadata; it may fail if required metadata is absent. Repository signatures and package signature policy matter. Do not use rpm --nodeps or --nosignature as routine fixes. Real DNF changes are VM-only.
Use the RPM name/version query to identify the installed record and the file listing to learn what paths that package records. If a recorded path is missing, the listing can still contain it. A DNF installed-list result is not a list of available upgrades. Cache-only mode avoids refreshing metadata, so do not interpret absent or stale information as proof that the system has all security updates. Compare the command status and diagnostics with the intended query; validate actual commands in the stated RHEL 9 VM.
Try the examples
RHEL 9 VM with Bash installed: expect a package identifier including version, release and architecture.
Manual example; not executed locally. Follow its stated environment restrictions.
The paths are recorded by RPM; this does not verify their current contents.
Manual example; not executed locally. Follow its stated environment restrictions.
With DNF 4 and populated local metadata, expect an installed Bash row; cache errors are possible.
Manual example; not executed locally. Follow its stated environment restrictions.
Common mistakes
RPM is not a replacement for DNF dependency resolution. Never install an RPM meant for another distribution or disable verification just to satisfy an error.
Practice
In a RHEL 9 VM compare rpm -q bash, rpm -ql bash and dnf --cacheonly list --installed bash. Record which command reads ownership or package identity; do not install anything.
Related references
Study: dnf, rpm. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
DNF and RPM — Knowledge Check
Apply package-management concepts to the stated distribution and query-only lab.
Which database does rpm -q read?
Which tool resolves dependencies from repositories?
What does rpm -ql bash show?
What should you do when DNF 5 syntax differs?