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

  1. Query Installed Packages:

    • Command: rpm -qa

    • Function: Displays all currently installed packages.

  2. Identify Package for a File:

    • Command: rpm -qf <filename>

    • Function: Reveals which package a specific file belongs to.

  3. List Files in a Package:

    • Command: rpm -ql <package>

    • Function: Shows all files that were installed from a specific package.

  4. Show Installation Scripts:

    • Command: rpm -q --scripts <package>

    • Function: Displays the scripts executed during the installation of the package.

  5. View Changelog:

    • Command: rpm -q --changelog <package>

    • Function: Displays the changelog of a specific package.

  6. 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 -v

    • Function: Converts the RPM package to a cpio archive format and lists the contents.

  • Extracting Files to Current Directory:

    • Command: rpm2cpio <package.rpm> | cpio -idmv

    • Function: 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/crypttab

    • Expected Output: Identifies that etc/crypttab is from the systemd-udev package.

  • Listing Files in a Package:

    • Example Command: rpm -ql systemd-udev

    • Expected Outcome: Shows the extensive list of files (e.g., 516 files) included in the systemd-udev package.

  • Query Configuration Files:

    • Example Command: rpm -qc systemd-udev

    • Functionality: Lists various configuration files associated with systemd-udev, helpful for configuring specific aspects of the service on a RHEL system.