Red Hat System Administration I · RH124

Chapter 12

Installing and Updating Software with RPM
RPM package format · dnf · Querying & verifying · Package history
CIS126RH — Mesa Community College

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 install
  • dnf update
  • dnf remove
  • rpm -q
  • rpm -V
  • dnf history

The RPM Package Format

RPM (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.

Why It Matters — You rarely install .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.

Anatomy of a Package Filename

httpd-2.4.57-5.el9.x86_64.rpm
PartMeaning
httpdPackage name
2.4.57Upstream version
5Release (packaging revision) number
el9Built for RHEL 9
x86_64Target architecture

Managing Software with dnf

# 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
Warning — dnf remove Can Cascade — Removing a package that other installed packages depend on will prompt to remove those dependents too. Read the transaction summary dnf prints before confirming — it's easy to remove more than you intended.

Searching and Investigating Packages

# 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
Tip — provides Is a Lifesaver — Don't know which package installs a particular command or file? dnf provides answers that instantly, without guessing at package names.

Querying with rpm

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
Exam Note — Remember the query flag pattern: -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).

Verifying Packages

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
CodeMeaning
SFile size differs
5MD5 checksum differs (content changed)
TModification time differs
cMarks the entry as a configuration file
Tip — Expected vs. Unexpected Changes — A changed 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.

History and Rollback

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
Warning — Rollback Isn't Always Cleandnf 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.

Key Terms for Chapter 12

RPM
RPM Package Manager; both the package file format and the low-level tool that manages it
dnf
The high-level package management tool that resolves dependencies and installs from repositories
dependency
A package required by another package in order to function
repository (repo)
A collection of installable packages that dnf can pull from
rpm -q
Query mode; used to inspect installed packages or .rpm files directly
rpm -V
Verify mode; compares installed package files against their original recorded state
dnf history
Records past dnf transactions and allows undoing or redoing them

Review Questions

  1. In the filename bash-5.1.8-6.el9.x86_64.rpm, what do el9 and x86_64 each indicate?
  2. What is the relationship between rpm and dnf?
  3. Write a command that lists every file installed by the httpd package.
  4. You find a file on disk and want to know which package installed it. What command answers that?
  5. What does it mean when rpm -V somepackage reports no output at all?
  6. In rpm -V output, what does the code 5 indicate about a file?
  7. You applied a dnf update yesterday and something broke. What command would you use to review that transaction, and what command would undo it?
1 / 11