LPIC 102.5 Use RPM and YUM package management

Weight: 3

Description: Candidates should be able to perform package management using RPM and YUM tools.

Key Knowledge Areas:

  • Install, re-install, upgrade and remove packages using RPM and YUM
  • Obtain information on RPM packages such as version, status, dependencies, integrity and signatures
  • Determine what files a package provides, as well as find which package a specific file comes from

Terms and Utilities:

  • rpm
  • rpm2cpio
  • /etc/yum.conf
  • /etc/yum.repos.d/
  • yum
  • yumdownloader

RPM Database

  • The RPM database is a collection of Berkeley DB1 files.
  • The RPM database is located in the /var/lib/rpm directory.
  • Rebuild the database from the installed package’s headers with command rpm --rebuilddb.
  • Information about an installed package comes from RPM DB.

RPM Package

  • Two types of .rpm packages: binary and source
  • Information about an uninstalled package comes from .rpm file.

Package Name Conventions

Installed packages are known by a short name.

Here’s an example of a short package name:
wireshark

Typically, long package names are needed for deletions when
multiple packages whose short names match exist.

Here’s an example of a long package name:
$ rpm -q kernel
kernel-3.10.0-327.36.3.el7.x86_64
kernel-3.10.0-327.el7.x86_64

rpm Command

Common operations that use the rpm command include

  • Verifying the package file
    RPM has two checks it uses to ensure the integrity of a package: MD5 and PGP
# yum install --downloadonly mlocate
# cd /var/cache/yum/x86_64/7/base/packages
# rpm -K mlocate-0.26-5.el7.x86_64.rpm
mlocate-0.26-5.el7.x86_64.rpm: rsa sha1 (md5) pgp md5 OK  
  • Installing packages
    rpm -ivh mlocate-0.26-5.el7.x86_64.rpm
    i - install
    v - verbose
    h - progress bar
    rpm -ivh --force mlocate-0.26-5.el7.x86_64.rpm
    use force option to overwrite existing files

  • Upgrading packages
    rpm -U *.rpm
    upgrades all packages in current folder to your system
    The -U and --upgrade options upgrade packages that are already installed and install packages that aren’t

  • Removing and uninstalling packages
    using the -e or --erase option to remove/uninstall a package: rpm -e tarfoo

  • Checking installed files
    Verify an installed RPM with the -V option (or --verify ) like so:
    rpm -V logrotate
    To verify the state of all the packages on the system, you add an - a instead of specifying a package name, as such:
    # rpm -Va
    Check all configuration files on your system:
    rpm -Vac

  • Querying the RPM database for information

YUM Yellowdog Updater Modified

Installing Packages

  • Install a package yum install package
  • 3 ways to download packages without installation:
    • At the y/d/N prompt above, answer d (download) instead of y (yes)
    • Use yum install --downloadonly
# Install the downloadonly plugin
yum install yum-plugin-downloadonly  
yum install --downloadonly --downloaddir=<directory> <package-name>  
  • Use yumdownloader instead of yum
# Install the yumdownloader tool
yum install yum-utils  
yumdownloader --resolve httpd  
# ---Options---
# destdir - specifies the location the files will be stored
# source - downloads the source RPM instead of binary RPM  
# resolve - modifies the command to also include any missing dependencies

Fetching Updates

  • check for any out-of-date packages with yum check-update
  • upgrade the whole system with yum update
  • upgrade specific package yum update [package_name]

Finding Packages to Install

  • yum list PACKAGE* search package and components(shares common prefix)
  • yum search KEYWORD search repository description content

Configuration files

  • /etc/yum.conf
  • /etc/yum.repos.d/*
  • command enable some yum repository: yum --enablerepo NAME

  1. Berkeley DB (BDB) is a software library intended to provide a high-performance embedded database for key/value data. Wikipedia