Managing RPM Packages
Overview of RPM Packages
Definition: RPM (Red Hat Package Manager) packages are used for installing software on Red Hat Enterprise Linux (RHEL).
Components of RPM Package:
Contains a compressed archive.
Includes packaged metadata which identifies package dependencies.
Dependency Management
Tools Used: RHEL relies on DNF (Dandified YUM) and repositories to manage dependencies automatically during package installations.
Note: Do not use the older RPM command for installing packages; use DNF instead.
RPM Database
Registration: All installed packages are recorded in the RPM database.
Usage of RPM Command: The RPM command can be used for querying and analyzing package content based on database information.
Common RPM Commands for Database Querying
Query Installed Packages:
Command:
rpm -qaFunction: Displays all currently installed packages.
Identify Package for a File:
Command:
rpm -qf <filename>Function: Reveals which package a specific file belongs to.
List Files in a Package:
Command:
rpm -ql <package>Function: Shows all files that were installed from a specific package.
Show Installation Scripts:
Command:
rpm -q --scripts <package>Function: Displays the scripts executed during the installation of the package.
View Changelog:
Command:
rpm -q --changelog <package>Function: Displays the changelog of a specific package.
Query a Local Package File:
Command:
rpm -qp <package file>Function: Queries information from a package file located locally instead of the database.
Extracting RPM Packages
Extract without Installation:
Command:
rpm2cpio <package.rpm> | cpio -t -vFunction: Converts the RPM package to a cpio archive format and lists the contents.
Extracting Files to Current Directory:
Command:
rpm2cpio <package.rpm> | cpio -idmvFunction: Extracts the files from the RPM package into the current working directory.
Use Case: Useful if you need to work with specific files inside the package without fully installing it.
Practical Demo of RPM Usage
RPM Command Usage:
Example Command:
rpm -qf /etc/crypttabExpected Output: Identifies that
etc/crypttabis from thesystemd-udevpackage.
Listing Files in a Package:
Example Command:
rpm -ql systemd-udevExpected Outcome: Shows the extensive list of files (e.g., 516 files) included in the
systemd-udevpackage.
Query Configuration Files:
Example Command:
rpm -qc systemd-udevFunctionality: Lists various configuration files associated with
systemd-udev, helpful for configuring specific aspects of the service on a RHEL system.