Chapter Objective
Install, update, remove, and query software packages on RHEL using dnf and the underlying RPM package format, and verify installed packages for integrity.
Key Commands
dnf installdnf updatednf removerpm -qrpm -Vdnf history
Install, update, remove, and query software packages on RHEL using dnf and the underlying RPM package format, and verify installed packages for integrity.
dnf installdnf updatednf removerpm -qrpm -Vdnf historyRPM (RPM Package Manager) is the underlying package format RHEL software is distributed in. An RPM file bundles a program's files, metadata (version, dependencies, description), and installation scripts into a single .rpm archive.
.rpm files directly. Instead, you use dnf, a higher-level tool that resolves dependencies automatically and pulls packages from configured repositories — but everything it installs still ends up as RPM packages underneath.
httpd-2.4.57-5.el9.x86_64.rpm
| Part | Meaning |
|---|---|
httpd | Package name |
2.4.57 | Upstream version |
5 | Release (packaging revision) number |
el9 | Built for RHEL 9 |
x86_64 | Target architecture |
# Install a package (resolves and installs dependencies automatically) sudo dnf install httpd # Install without a confirmation prompt sudo dnf install -y httpd # Remove a package sudo dnf remove httpd # Update a specific package sudo dnf update httpd # Update every installed package sudo dnf update # Check what updates are available without installing them dnf check-update
# Search package names and summaries for a keyword dnf search webserver # Show detailed information about a package dnf info httpd # List installed packages dnf list installed # List packages available to install dnf list available # Find which package provides a specific file or command dnf provides /usr/sbin/httpd dnf provides */ssh-keygen
dnf provides answers that instantly, without guessing at package names.
While dnf handles installation, the lower-level rpm command is still the standard tool for querying details about installed packages and inspecting .rpm files directly.
# Check whether a package is installed, and its version rpm -q httpd # Show detailed information about an installed package rpm -qi httpd # List every file a package installed rpm -ql httpd # Show a package's documentation files rpm -qd httpd # Find which package owns a specific file already on disk rpm -qf /usr/sbin/httpd # Query a downloaded .rpm file before installing it rpm -qip package.rpm
-q is always paired with a modifier — i (info), l (list files), f (which package owns a file), p (query a package file directly rather than the installed database).
rpm -V compares a package's currently installed files against the checksums and metadata recorded at install time, flagging anything that has changed.
# Verify a package's files against their original state rpm -V httpd # No output means everything matches — nothing has changed # Example output showing a modified configuration file S.5....T. c /etc/httpd/conf/httpd.conf
| Code | Meaning |
|---|---|
S | File size differs |
5 | MD5 checksum differs (content changed) |
T | Modification time differs |
c | Marks the entry as a configuration file |
c) is often normal — you edited it on purpose. Changes to a binary in /usr/bin or /usr/sbin are far more suspicious and worth investigating immediately.
dnf keeps a record of every transaction, which makes it possible to review what changed and undo a problematic update.
# List recent dnf transactions dnf history # Show details of a specific transaction dnf history info 42 # Undo (roll back) a specific transaction sudo dnf history undo 42 # Redo a previously undone transaction sudo dnf history redo 42
dnf history undo reverses package changes, but it can't undo configuration file edits or data changes an application made after the update. Treat it as a recovery option, not a guaranteed full restore.
bash-5.1.8-6.el9.x86_64.rpm, what do el9 and x86_64 each indicate?rpm and dnf?httpd package.rpm -V somepackage reports no output at all?rpm -V output, what does the code 5 indicate about a file?