Study guide

4.3 RPM Package Management with rpm (102.5)

LPIC-1 Linux Administrator — Exam 101 101-500

Track your progress as you read

Finished sections get a check mark.

1 Exam Overview & Study Strategy

1.1 LPIC-1 101-500 Exam Structure & Blueprint 1.2 Command Line & Shell Fundamentals for Exam Success 1.3 Fill-in-the-Blank Strategies & Common Traps

2 Topic 101: System Architecture

2.1 Hardware Discovery, Sysfs, Procfs & Kernel Modules (101.1) 2.2 Udev, Dbus & Device Management (101.1) 2.3 BIOS vs. UEFI & System Boot Process (101.2) 2.4 Kernel Initialization, Initramfs & System Logs (101.2) 2.5 Systemd Boot Targets & Unit Management (101.3) 2.6 SysVinit Runlevels, Telinit & System Shutdown (101.3)

3 Topic 102: Linux Installation & Boot Management

3.1 Hard Disk Layout, Partition Schemes & Swap Design (102.1) 3.2 LVM & Standard Mount Point Allocation (102.1) 3.3 GRUB 2 Configuration & Troubleshooting (102.2) 3.4 Legacy GRUB & Alternative Boot Loaders (102.2) 3.5 Managing Shared Libraries & ldconfig (102.3) 3.6 Linux as a Virtualization Guest & Cloud Instances (102.6)

4 Topic 102: Package Management Systems

4.1 Debian Low-Level Package Management with dpkg (102.4) 4.2 High-Level Debian Package Management: apt, apt-get & apt-cache (102.4) 4.3 RPM Package Management with rpm (102.5) 4.4 YUM, DNF & Zypper Package Management (102.5) 4.5 Package Repositories & Integrity Verification (102.4/102.5) 4.6 Universal Linux Packages: Snap, Flatpak & AppImage (102.4/102.5)

5 Topic 103: Command Line & Text Processing

5.1 Shell Environment, Environment Variables & Aliases (103.1) 5.2 Command History, Quoting & Expansion (103.1) 5.3 Basic Text Filters: cat, head, tail, cut, paste, nl, od (103.2) 5.4 Advanced Text Filters: sort, uniq, wc, tr, split, less & Checksums (103.2) 5.5 Stream Editing with sed (103.2) 5.6 Basic File Management: cp, mv, rm, touch, mkdir, rmdir (103.3) 5.7 Archiving and Compression: tar, gzip, bzip2, xz, cpio & dd (103.3)

6 Topic 103: Streams, Processes, Regex & Vi

6.1 Standard Streams, Redirection & File Descriptors (103.4) 6.2 Pipelines, tee & xargs (103.4) 6.3 Process Monitoring: ps, top, free, watch, pgrep, pstree & uptime (103.5) 6.4 Signals, kill, Job Control, nohup, screen & tmux (103.5) 6.5 Process Priorities: nice & renice (103.6) 6.6 Regular Expressions & grep, egrep, fgrep (103.7) 6.7 vi / vim Modes, plus nano, Emacs & EDITOR Awareness (103.8)

7 Topic 104: Devices, Partitions & Filesystems

7.1 Block Devices, fdisk & gdisk (104.1) 7.2 GNU Parted & Partition Table Management (104.1) 7.3 Creating Filesystems: mkfs, ext4, XFS, VFAT/exFAT & Btrfs (104.1) 7.4 Filesystem Integrity: fsck, e2fsck, xfs_repair, xfs_fsr & xfs_db (104.2) 7.5 Monitoring Disk Usage: df, du & tune2fs (104.2) 7.6 Managing Swap Space: mkswap, swapon & swapoff (104.1/104.2)

8 Topic 104: Mounts, Permissions, Links & FHS

8.1 Mounting and Unmounting Filesystems: mount & umount (104.3) 8.2 Persistent Mounts: /etc/fstab, UUIDs & systemd mount units (104.3) 8.3 Standard File Permissions: chmod, chown, chgrp & umask (104.5) 8.4 Special Permissions: SUID, SGID & Sticky Bit (104.5) 8.5 Hard Links vs. Symbolic Links: ln & Inodes (104.6) 8.6 Filesystem Hierarchy Standard (FHS) & File Location (104.7)

4.3 RPM Package Management with rpm (102.5)

Key Takeaways Explain This Topic AI

RPM package filenames follow the standard convention name-version-release.architecture.rpm, while queries on installed packages target the package name.

Core RPM lifecycle modes include install (-i), upgrade-or-install (-U), freshen (-F), and erase (-e).

Querying uninstalled .rpm archive files requires adding the -p flag (e.g., rpm -qip, rpm -qlp, rpm -qcp, rpm -qRp).

RPM verification (rpm -V) tests installed file attributes against the RPM database using an 8-character code checking size (S), permissions (M), digest checksum (5), and modification time (T).

Files can be extracted from an .rpm package without installation using the pipeline: rpm2cpio package.rpm | cpio -idmv.

Last updated: August 2026

4.3 RPM Package Management with rpm (102.5)

Quick Summary: The RPM Package Manager ( rpm ) is the foundational low-level package management tool utilized across Red Hat Enterprise Linux (RHEL), CentOS, Fedora, Rocky Linux, AlmaLinux, and openSUSE. Similar to Debian's dpkg , the rpm utility works directly with local .rpm archive files and queries the local RPM database located in /var/lib/rpm/ . It handles installation, querying, verification, and uninstallation, but does not automatically download packages over a network or resolve missing multi-package dependencies.

1. RPM Package Architecture & Naming Conventions

Every RPM binary package filename adheres to a strict five-element naming structure. Candidates on the LPIC-1 exam must be able to decompose an RPM filename into its constituent parts. httpd - 2.4.51 - 1.el9 . x86_64 .rpm

  • └──┬──┘ └───┬───┘ └───┬───┘ └───┬──┘
  • Name Version Release Architecture
  • RPM Naming Components

Package Name ( name ) : The base identifier of the software application (e.g., httpd , bash , kernel , bind ).

Version ( version ) : The upstream software developer's release version (e.g., 2.4.51 , 5.2.15 ).

Release ( release ) : The distribution maintainer's build and revision count, often containing OS release tags (e.g., 1.el9 indicates build 1 for Enterprise Linux 9; 3.fc38 indicates build 3 for Fedora 38).

Architecture ( architecture ) : The target hardware instruction set architecture:

  • x86_64 : 64-bit AMD/Intel x86 processors
  • aarch64 : 64-bit ARM processors
  • i686 / i386 : 32-bit x86 legacy systems

noarch : Architecture-independent packages containing documentation, Python/Perl scripts, or assets.

Extension ( .rpm ) : Standard file extension for RPM package archives.

⚠️ LPIC-1 Trap: When installing or upgrading software using rpm -i or rpm -U , you must provide the full path or filename of the .rpm file (e.g., httpd-2.4.51-1.el9.x86_64.rpm ). When querying or erasing an installed package with rpm -q or rpm -e , you specify only the package name (e.g., httpd ).

2. Package Lifecycle Modes: Install, Upgrade, Freshen & Erase

The rpm utility operates in one of several primary modes specified by leading flags, typically combined with formatting modifiers ( -v for verbose, -h for hash progress marks).

Command Syntax Operation Mode Behavior If Package Is NOT Installed Behavior If Older Version IS Installed

rpm -ivh <file.rpm> Install ( -i ) Installs the package normally. Fails with an error reporting that the package or conflicting files exist.

rpm -Uvh <file.rpm> Upgrade ( -U ) Installs the package as new. Upgrades the package to the newer version and uninstalls the older version.

rpm -Fvh <file.rpm> Freshen ( -F ) Does nothing. (Skips package entirely). Upgrades the package to the newer version.

rpm -e <pkg_name> Erase ( -e ) Reports package not installed. Uninstalls and removes the specified package. # Standard installation with progress hash marks

  • $ sudo rpm -ivh httpd-2.4.51-1.el9.x86_64.rpm
  • Verifying... ################################# [100%]
  • Preparing... ################################# [100%]

Updating / installing...

  • 1:httpd-2.4.51-1.el9 ################################# [100%]
  • Critical rpm Modifier Flags

-v : Verbose mode; displays detailed step-by-step progress.

-h , --hash : Prints 50 hash marks ( # ) across the terminal to visualize unpacking progress.

--test : Simulates the installation, upgrade, or removal without modifying disk state or the RPM database.

--nodeps : Disables pre-transaction dependency checks. Forces installation or removal even if prerequisites are missing (dangerous).

--force : Shorthand equivalent to --replacepkgs --replacefiles . Forces installation even if the package or its files already exist on disk.

--replacepkgs : Reinstalls a package even if the database indicates it is already installed.

--replacefiles : Installs files even if they conflict with or overwrite files owned by another installed package.

--oldpackage : Allows downgrading a package to an older version during an rpm -U operation.

--noscripts : Prevents execution of %pre , %post , %preun , and %postun maintainer scripts.

3. Querying the RPM Database: Installed Packages vs. RPM Files

Query mode ( -q ) interrogates either the local RPM database ( /var/lib/rpm/ ) or an uninstalled .rpm package file when paired with the -p (package file) modifier.

  • Querying Installed Packages # Query all installed packages on the system
  • $ rpm -qa | grep nginx
  • # Display detailed package metadata, license, architecture, and description
  • $ rpm -qi nginx
  • # List all files installed onto the filesystem by the nginx package
  • $ rpm -ql nginx
  • # Identify which package owns a specific file on the filesystem
  • $ rpm -qf /etc/nginx/nginx.conf
  • nginx-1.22.1-9.el9.x86_64
  • # List ONLY configuration files installed by the package
  • $ rpm -qc nginx
  • # List ONLY documentation files and man pages installed by the package
  • $ rpm -qd nginx
  • # Display embedded pre/post installation shell scripts
  • $ rpm -q --scripts nginx
  • # List virtual capabilities and features provided by the package
  • $ rpm -q --provides nginx
  • # List all prerequisites and capabilities required by the package
  • $ rpm -q --requires nginx # OR: rpm -qR nginx
  • # Display change history log recorded by package maintainers
  • $ rpm -q --changelog nginx
  • Querying Uninstalled .rpm Package Files ( -p Flag)

To query a package file that resides on disk but is not yet installed , you must append the -p flag and provide the full filename: # View description and metadata of an uninstalled RPM file

$ rpm -qip httpd-2.4.51-1.el9.x86_64.rpm

  • # List all files that WILL be installed by the RPM archive
  • $ rpm -qlp httpd-2.4.51-1.el9.x86_64.rpm
  • # List configuration files inside the uninstalled archive
  • $ rpm -qcp httpd-2.4.51-1.el9.x86_64.rpm
  • # Check prerequisites required by the uninstalled archive
  • $ rpm -qp --requires httpd-2.4.51-1.el9.x86_64.rpm
  • 4. Package Integrity Verification & Test Codes ( rpm -V )

The verification mode ( -V or --verify ) compares file attributes on the live filesystem against the original metadata recorded in the RPM database during installation. If a file has not been altered, rpm -V outputs nothing. If differences exist, an 8-character status string is displayed. # Verify a specific installed package

  • $ rpm -V httpd
  • S.5....T. c /etc/httpd/conf/httpd.conf
  • ..5...... /usr/sbin/httpd
  • # Verify ALL packages installed on the entire operating system
  • $ sudo rpm -Va
  • # Verify the package that owns a specific file
  • $ rpm -Vf /etc/ssh/sshd_config
  • Verification Test Code Reference Table

Each character position in the 8-character output string represents a specific attribute test:

Code Position Test Character Attribute Inspected Failure Meaning

Position 1 S File Size The physical byte size of the file has changed.

Position 2 M Mode / Permissions File permissions ( rwx ) or file type (file vs. symlink) has changed.

Position 3 5 MD5 / SHA256 Digest Cryptographic hash mismatch; file content has been modified .

Position 4 D Device Major/Minor Device node major/minor numbers mismatch.

Position 5 L Symlink Path Destination path of a symbolic link ( readlink ) has changed.

Position 6 U User Ownership The file's user owner (UID) has changed.

Position 7 G Group Ownership The file's group owner (GID) has changed.

Position 8 T Modification Time (mTime) The file's last modified timestamp differs from installation.

Position 9 P Capabilities Extended process capabilities differ.

Any Position . Test Passed The corresponding attribute matches the RPM database exactly.

Suffix Flag c Configuration File Indicates the file is flagged as a %config configuration file.

Suffix Flag d Documentation File Indicates the file is flagged as a %doc documentation file.

💡 LPIC-1 Exam Fill-in-the-Blank Alert: In rpm -V output, 5 indicates that the MD5 or SHA256 checksum/digest failed (content changed), S indicates file size changed, and M indicates file permissions/mode changed.

5. Extracting Archive Files with rpm2cpio & cpio

When a critical system binary (such as /bin/ls or /lib64/libc.so.6 ) is accidentally deleted or corrupted, running a standard package manager may fail because the package manager itself depends on the missing binary. Administrators can extract individual files directly from an .rpm file without installing it or modifying /var/lib/rpm/ using rpm2cpio piped into cpio . # Step 1: Create a temporary restoration directory

mkdir /tmp/rescue && cd /tmp/rescue

  • # Step 2: Convert RPM payload to cpio archive and extract
  • rpm2cpio /path/to/coreutils-8.32-34.el9.x86_64.rpm | cpio -idmv
  • # Step 3: Inspect extracted filesystem tree in /tmp/rescue
  • ls -l /tmp/rescue/usr/bin/ls
  • # Step 4: Copy the restored binary to its system location
  • sudo cp /tmp/rescue/usr/bin/ls /usr/bin/ls
  • cpio Extraction Flag Breakdown

-i ( --extract ): Run cpio in input/extract mode.

-d ( --make-directories ): Automatically create leading directories as needed.

-m ( --preserve-modification-time ): Retain original file modification timestamps.

-v ( --verbose ): Print names of files as they are unpacked.

Loading diagram... RPM Query & Verification Decision Tree