Popular Searches

Inspect DNF History and Package Integrity

LinuxBeginner
Practice Now

Introduction

After learning basic repository configuration, the next software management skill is inspection. Administrators often need to answer practical questions without changing the system: what package transactions happened, which package owns a file, and whether package-managed files still match the RPM database.

In this lab, you will use local DNF and RPM queries only. You will inspect DNF transaction history, examine one history record, use dnf repoquery --installed and rpm -qf to find package providers, verify installed packages with rpm -V, and perform a small ownership readiness check across common command paths.

Inspect DNF Transaction History

In this step, you will inspect DNF transaction history. DNF records package transactions such as installs, updates, and removals. This history is useful when you need to understand what changed before a problem appeared.

Move into the standard LabEx project directory.

cd /home/labex/project

List recent DNF history entries. The output includes a transaction ID, command line, date, actions, and number of altered packages.

sudo dnf history list | sed -n '1,8p'

The exact transaction IDs and dates may vary, but the table header should include ID, Command line, Action(s), and Altered.

Inspect One History Transaction

In this step, you will inspect details for one transaction. A history list gives a summary; dnf history info shows details such as the transaction ID, command line, begin time, end time, and affected packages.

Capture the most recent transaction ID from the history table.

latest_id="$(sudo dnf history list | awk 'NR==3 {print $1}')"
echo "latest transaction: $latest_id"

Inspect that transaction. The sed command keeps the output focused on the first part of the report.

sudo dnf history info "$latest_id" | sed -n '1,40p'

Look for fields such as Transaction ID, Begin time, Command Line, and Packages Altered. These fields help you reconstruct package activity during troubleshooting.

Find Installed Package Providers

In this step, you will identify which installed package provides a command path. This is useful when you find a file on disk and need to know which package owns it.

Use DNF's installed-package query to find the provider for /usr/bin/bash.

dnf repoquery --installed --whatprovides /usr/bin/bash

Ask RPM the same question with rpm -qf. The -f option means query by file path.

rpm -qf /usr/bin/bash

Repeat the provider query for /usr/bin/cp, which comes from coreutils.

dnf repoquery --installed --whatprovides /usr/bin/cp
rpm -qf /usr/bin/cp

The two tools format the answer differently, but both should identify the installed package that owns the file.

Verify Package Integrity

In this step, you will use RPM verification. rpm -V compares installed package-managed files against RPM database metadata such as size, permissions, owner, group, digest, and timestamp.

Verify the bash package.

rpm -V bash

Verify the coreutils package.

rpm -V coreutils

These commands normally print no output when verification passes. To make the successful state visible in the terminal, print a short confirmation after the checks.

echo "bash and coreutils package verification completed"

No output from rpm -V is good news: it means RPM did not find differences for the checked package-managed files.

Check Ownership for Common Commands

In this step, you will perform a compact readiness check across several command paths. This is the kind of quick inspection an administrator uses when validating a system or investigating where a command came from.

Loop over three common command paths and print the owning package for each one.

for path in /usr/bin/bash /usr/bin/cp /usr/bin/ssh; do
  printf '%s -> ' "$path"
  rpm -qf "$path"
done

The expected package names are bash, coreutils, and openssh-clients. Versions and releases can vary, so focus on the package name prefix.

Confirm that DNF history is still readable after your package inspection work.

sudo dnf history list | sed -n '1,5p'

This final step ties together the local package database and transaction history views without making system changes.

Summary

You practiced local software inspection workflows that are useful before and after package changes. You reviewed DNF transaction history, inspected one transaction, identified package providers with DNF and RPM, verified package-managed files with rpm -V, and checked ownership for common command paths.