102.5: Use RPM and YUM Package Management

Mastering RPM and YUM Package Management for LPIC-1 Certification #

Introduction #

Package management is a critical skill for any Linux system administrator. The LPIC-1 certification exam tests your ability to manage packages using RPM, YUM, and Zypper. In this tutorial, we’ll cover the essentials of these tools, with real-world code examples, to help you confidently manage packages on RPM-based Linux distributions.

RPM (Red Hat Package Manager) #

Installing Packages #

To install a package using RPM, use the -i option. For example:

sudo rpm -i example-package.rpm

Re-installing Packages #

To re-install a package, use the --replacepkgs option:

sudo rpm -i --replacepkgs example-package.rpm

Upgrading Packages #

To upgrade a package, use the -U option. If the package is not already installed, this command will install it:

sudo rpm -U example-package.rpm

Removing Packages #

To remove a package, use the -e option:

sudo rpm -e example-package

Obtaining Package Information #

To get information about an installed package, use the -q option:

rpm -q example-package

To check package version:

rpm -q example-package --qf "%{VERSION}\n"

To see package dependencies:

rpm -qR example-package

Verifying Package Integrity #

To verify the integrity of a package, use the -V option:

rpm -V example-package

Extracting Package Files #

To extract files from an RPM package, use rpm2cpio:

rpm2cpio example-package.rpm | cpio -idmv

YUM (Yellowdog Updater, Modified) #

YUM is a higher-level package manager that resolves dependencies and makes package management easier.

Installing Packages #

To install a package using YUM, use the install command:

sudo yum install example-package

Re-installing Packages #

To re-install a package, use the reinstall command:

sudo yum reinstall example-package

Upgrading Packages #

To upgrade all packages, use the update command:

sudo yum update

To upgrade a specific package:

sudo yum update example-package

Removing Packages #

To remove a package, use the remove command:

sudo yum remove example-package

Obtaining Package Information #

To get information about a package:

yum info example-package

Listing Available Packages #

To list all available packages:

yum list available

Checking for Updates #

To check if updates are available for installed packages:

yum check-update

Zypper (SUSE Linux) #

Installing Packages #

To install a package using Zypper:

sudo zypper install example-package

Re-installing Packages #

To re-install a package:

sudo zypper install --force example-package

Upgrading Packages #

To upgrade all installed packages:

sudo zypper update

Removing Packages #

To remove a package:

sudo zypper remove example-package

Obtaining Package Information #

To get information about a package:

zypper info example-package

Awareness of DNF #

DNF (Dandified YUM) is the next-generation version of YUM. It is used in Fedora and RHEL 8+.

Installing Packages #

To install a package using DNF:

sudo dnf install example-package

Re-installing Packages #

To re-install a package:

sudo dnf reinstall example-package

Upgrading Packages #

To upgrade all installed packages:

sudo dnf upgrade

Removing Packages #

To remove a package:

sudo dnf remove example-package

Obtaining Package Information #

To get information about a package:

dnf info example-package

Configuration Files #

/etc/yum.conf #

The main configuration file for YUM, which contains global options for the YUM package manager.

/etc/yum.repos.d/ #

This directory contains repository configuration files for YUM. Each file in this directory specifies a repository that YUM can use to download and install packages.

Conclusion #

Mastering RPM, YUM, and Zypper package management tools is essential for any Linux administrator, and understanding these tools will help you succeed in the LPIC-1 certification exam. With these commands and concepts, you’ll be well-equipped to handle package management tasks on any RPM-based Linux distribution.