Install and remove RPM software packages

2. Manage Software

πŸ“˜Red Hat Certified System Administrator (RHCSA – EX200)


1. What is an RPM Package?

  • RPM stands for Red Hat Package Manager.
  • It is the default package format used in RHEL, CentOS, Rocky Linux, AlmaLinux, and other Red Hat-based Linux systems.
  • An RPM package is like a container that holds a program, its files, and metadata (version, dependencies, etc.).
  • Files end with .rpm, e.g., vim-9.0-1.el9.x86_64.rpm.

IT Example:
On a web server, installing httpd via RPM will place all web server files (binaries, configs, logs) in their correct locations.


2. Basic RPM Commands

2.1 Install a Package

rpm -ivh package_name.rpm
  • -i β†’ install
  • -v β†’ verbose (shows progress)
  • -h β†’ hash marks for progress

Example:

rpm -ivh vim-9.0-1.el9.x86_64.rpm

This installs Vim editor on the system.

Important notes:

  • Dependencies: RPM does not automatically resolve dependencies. If a package needs other packages, it will fail unless they are installed.
  • File locations: RPM keeps track of all files it installs, so uninstalling is easier.

2.2 Upgrade a Package

rpm -Uvh package_name.rpm
  • -U β†’ upgrade (installs if not present, replaces if already installed)

Example:

rpm -Uvh vim-9.1-1.el9.x86_64.rpm

This upgrades Vim to version 9.1 if an older version exists.


2.3 Remove a Package

rpm -e package_name
  • -e β†’ erase/remove package
  • Only the package name is needed, not the full file name

Example:

rpm -e vim

This removes Vim and all files installed by RPM.


3. Checking Installed Packages

Before removing or upgrading, you often check which packages are installed.

rpm -qa
  • -q β†’ query
  • -a β†’ all

Example:

rpm -qa | grep vim

This will show all installed Vim packages.


4. Querying Package Details

You can see more information about a package:

rpm -qi package_name
  • Shows version, release, install date, summary, and license.
rpm -ql package_name
  • Lists all files installed by that package.
rpm -qc package_name
  • Lists configuration files only.
rpm -q --requires package_name
  • Shows dependencies required by the package.

5. Verifying Packages

After installation, you can verify if files are intact:

rpm -V package_name
  • If everything is okay, it shows no output.
  • If files are modified, it lists the changes (useful for IT admins to detect tampering).

6. Installing RPMs with Dependencies (Using dnf or yum)

  • In practice, RPM alone often fails if dependencies are missing.
  • In production, admins use dnf (or yum in older systems) because it resolves dependencies automatically.
dnf install package_name.rpm
  • It works like RPM but ensures all required libraries and packages are installed first.

IT Example:
Installing a database server like mysql-server.rpm may need libaio and libgcc dependencies. dnf install handles this automatically.


7. Key Exam Points for RHCSA

For the exam, you must be able to:

  1. Install an RPM package using rpm -i or dnf install.
  2. Remove a package using rpm -e.
  3. Query installed packages using rpm -qa, rpm -qi, rpm -ql.
  4. Verify a package using rpm -V.
  5. Understand dependencies and that rpm does not auto-resolve them, but dnf does.

Tip: RHCSA exam might give you an RPM file and ask you to install it or remove an existing package. Always check:

  • Does it install correctly?
  • Are dependencies missing?

8. Example Exam Scenario

Task: Install nano-6.4.rpm and check if it works.

rpm -ivh nano-6.4.rpm
rpm -qa | grep nano
nano --version

Task: Remove Vim package:

rpm -e vim
rpm -qa | grep vim  # should return nothing

Task: Check which files were installed by httpd:

rpm -ql httpd

βœ… Summary Table for Quick Review

ActionRPM CommandNotes
Installrpm -ivh package.rpmFails if dependencies missing
Upgraderpm -Uvh package.rpmInstalls if not already installed
Removerpm -e package_nameOnly package name needed
Query all installedrpm -qaLists all packages
Query detailsrpm -qi package_nameShows info about package
List filesrpm -ql package_nameShows all installed files
Verify packagerpm -V package_nameChecks file integrity

This covers everything you need to know for RHCSA EX200 regarding RPM installation and removal. After mastering these, you’ll be ready to handle packages on your exam confidently.

Buy Me a Coffee