Skip to content

Red Hat RPM and YUM Package Management

Red Hat Package Manager and YUM are powerful package managers that allow the administrator to install, remove, and obtain package information. It is a software distribution method widely used in various Linux distributions, such as Red Hat Enterprise Linux, CentOS, and Fedora.

Red Hat RPM and YUM Package Management makes it possible to install packages , perform software updates, software groups, and dozens of other tasks. It’s as powerful as dpkg and apt-get.

This package manager performs in a way simple installation, maintenance, and removal of software packages.

Each rpm package contains binary programs, configuration files, documentation, and information from
how they should be installed and their dependencies.

This utility maintains a database of all installed packages and their files, version control, and dependencies.

In some special situations, the database may become corrupt. The package manager has special functions to recover its integrity.

The rpm packages have the following nomenclature:

![](https://www.certificacaolinux.com.br/wp-content/uploads/2019/03/IMAGEM06.png)
- Package\_name: As with Debian packages, an rpm package has a short name that describes its content. If more than one word is used, the dash is used; - Software Version: Each rpm file has its own version, which may vary according to the packages. They are generally numeric and are separated from the name by a dash; - Software Distribution: Each file may also have a different distribution or packaging; - Architecture: The rpm package usually bears the name of the architecture for which it was assembled; - Suffix: It uses the ending .rpm for easy identification.

We can also find packages with names on package-version format.src.rpm. These packages contain the source files for a software and are mostly architecturally independent.

The rpm package manager is used by various Linux distributions. But the packages may differ in information. additional from one distribution to another. Always try to use packages made specifically for your distribution.

This manager also controls dependencies between packages. They contain information about the dependencies of each application, and this information is used during your installation or removal.

If the installation of a new package requires another, rpm will alert the administrator.

The rpm tool

The rpm command is responsible for installing, removing, updating, converting the packages. This command is first organized into operating modes, which may be: querying, verifying, integrating, installing, removing, updating, and reconstructing the rpm database. Each operating mode may or may not contain several options available.

The most common operating modes are:

To consult the rpm database

# rpm {-q|—query} [query options] package_name

Example:

# rpm —q bash

bash-2.05b-207

To check the status of packages with rpm

# rpm {-v|—Verify} package_name

Example:

# rpm -V snort-2.0.1-98.i586.rpm

package snort-2.0.1-98.i586.rpm is not installed

To verify the signature and integrity of packages with rpm

# rpm {-K|—CheckSig} package_name

Example:

# rpm -K libpcap-0.7.2-37.i586.rpm

libpcap-0.7.2-37.i586.rpm: sha1 md5 gpg OK

To install a new package with rpm:

# rpm {-i|—install} [installation options] package_name

Example:

# rpm —i libpcap-0.7.2-37.i586.rpm

To install a new package showing installation details:

# rpm —ivh libpcap-0.7.2-37.i586.rpm

Preparing… ######################################## [100%]

1:libcap ##################################################### [100%]

To update a package with rpm:

# rpm {-u|—upgrade} [installation options] package_name

Example:

# rpm -U libpcap-0.7.2-37.i586.rpm

package libpcap-0.7.2-37 is already installed

To remove a package with rpm:

# rpm {-e|—erase} [removal options] package_name

Example:

# rpm —and libpcap-0.7.2-37.i586.rpm

To remake the bank of RPM data:

# rpm {—initdb|—rebuilddb}

Example:

# rpm —initdb

To check the dependencies of a package with rpm:

# rpm {—qPr}

Example:

# rpm —QPr BitTorrent-5.2.2-1-python2.4.noarch.rpm

/usr/bin/python2.4

python >= 2.3

python (abi) = 2.4

python-crypto >= 2.0

python-psyco

python-twisted >= 2.0

python-zopeinterface

rpmlib (CompressedFilenames) = 2.6

To install a package ignoring dependencies (a very stupid thing to do):

# rpm {—ivh —nodeps}

Example:

# rpm -ivh —nodeps BitTorrent-5.2.2-1-python2.4.noarch.rpm

Preparing… ######################################## [100%]

1:BitTorrent #################################################### [100%]

To list the recently installed rpm packages:

# rpm {—qa —last}

Example:

# rpm -qa —last

kernel-headers.x86_64 Fri 06 Mar 2019 11:55:01 BRT

graphviz-gd.x86_64 Fri 06 Mar 2019 11:55:00 BRT

file-devel.x86_64 & nbsp; Fri, Mar 06, 2019 11:55:00 PDT

To find out which rpm package a file belongs to:

# rpm {—qf file}

Example:

# rpm -qf /usr/bin/htpasswd

httpd24-tools-2.4.10-15.58.amzn1.x86_64

To learn information about a particular installed package:

# rpm {—qi package_name}

Example:

# rpm -qi httpd24

Name: httpd24

Version: 2.4.10

Release: 15.58.amzn1

Architecture: x86_64

Install Date: Fri 13 Feb 2015 21:56:14 BRST

Group & nbsp;: System Environment/Daemons

Size: 3792099

To verify the integrity of the files installed with the database of packages:

# rpm {—Go}

Example:

# rpm -Go

to

S.5… T. c /etc/sysconfig/svnserve

… L… c /etc/localtime

..?… /usr/sbin/glibc_post_upgrade.x86_64

S.5… T. c /etc/httpd/conf/httpd.conf

..?… /usr/sbin/suexec

The options of
The most frequent package information queries are:

  • -a: Lists all packages installed on the system;
  • -f file: Lists the name of the package containing the searched file;
  • -p package-name: Shows whether a particular package is installed;
  • -i package-name: Shows extra information about a particular package;
  • -l package-name: Shows the list of files that a package contains;
  • -R packagename: Shows the list of dependencies that a package needs to be installed.

The options for installing and updating packages most frequent are:

  • —force: This option forces the installation of a package and its files even if it is already installed. This option even forces the installation of an older package on top of a newer one
  • -h: This option shows the installation progress;
  • —nodeps: This option disables the dependency check for the installation of a package;
  • -v: Shows extra information during installation and updating the packages;
  • -vv: Shows much more information during the installation and updating of the packages. Generally used by developers.

The options for uninstalling the packages are:

  • —nodeps: Disables dependency checking, uninstalling the package even if it is needed by others;
  • —test: Tests the removal of the package without actually removing it. It is useful for testing whether removing the package will cause any damage to the system or application.

Prefer when updating a package to a higher version new use the —U mode. So the oldest package will be removed, the new one will be installed and the settings will be maintained.

YUM Tool

Yum is an acronym for Yellow Dog Updater, Modified. It is a tool used to manage the installation and removal of packages in Linux distributions, which use the RPM system.

It is a file package manager similar to APT-GET that automatically deals with dependencies by computing them and solving what must be done to treat them.

It has a configuration file that specifies which repositories YUM should use to search and download
the RPM packages.

New RPM-based Linux will always have the YUM package manager installed. If you need to install YUM, it can be found on the site http://yum.baseurl.org.

The installation command is:

# rpm -ivh yum.rpm

YUM requires you to configure the package repositories in the yum.conf configuration file

Example:

# vi /etc/yum.conf
name=Fedora Core 3 — Fedora US mirror

baseurl= http://SERVERNAME/fedora/fedora/$releasever/$basearch/RPMS.os
name=Fedora Core 3 Updates — Fedora US mirror

baseurl=http://SERVERNAME/fedora/fedora/$releasever/$basearch/RPMS.updates

In addition to the /etc/yum.conf configuration file, YUM allows you to place repository configuration files in the /etc/yum.pos.d/ directory. This directory contains the settings for each repository.

You can add extra repositories or “beta-test” software repositories in the repository list of YUM.

Some yum commands:

  • yum list: List all available packages;
  • yum check-update or yum list updates: Check if there are packages available for an update;
  • yum update: Update your system;
  • yum install :Installs a specific package and its dependencies;
  • yum remove: Removes a specific package
  • yum info : Shows basic information for a given package.

See the examples:

To install a package with yum:

# yum install postgresql

Resolving Dependencies

Install 2 Package (s)

Is this ok [Y/n]: and

Package (s) data still to download: 3.0 M

(1/2): postgresql-9.0.4-5.fc15.x86_64.rpm ; | 2.8 MB 00:11

(2/2): postgresql-libs-9.0.4-5.fc15.x86_64.rpm | 203 kB 00:00

------------------------------------------------------------------------------------------

Total & nbsp; 241 Kb/s | 3.0 MB 00:12

Running Transaction

Installing: postgresql-libs-9.0.4-5.fc15.x86_64

1/2

Installing: postgresql-9.0.4-5.fc15.x86_64 2/2

Complete!

To update packages installed with yum:

# yum update

Plugins loaded: priorities, update-motd, upgrade-helper

amzn-main/latest

; Resolving dependencies

—> Performing transaction verification

---> The aws-cli.noarch package 0:1 .7.5-1.2.amzn1 will be updated

---> The aws-cli.noarch package 0:1 .7.12-1.3.amzn1 will be an update

—> Completed dependency resolution

& nbsp; Resolved dependencies

===============================================================

Package Arq. Repo Tam version.

============================================================================

Installing:

kernel & nbsp; x86_64 3.14.34-27.48.amzn1 amzn-updates 16 M

Updating:

; aws-cli noarch 1.7.12-1.3.amzn1 amzn-updates 604 k

Transaction Summary

& nbsp; ========================================================================== Install 1 Package (+4 Dependent packages)

Upgrade 1 Package

Total download size: 16 M

Is this ok [Y/d/n]:

To remove a package with yum:

# yum remove postgresql

Resolving Dependencies

---> Package postgresql.x86_64 0:9 .0.4-5.fc15 will be erased

Is this ok [Y/n]: and

Running Transaction

Erasing ;: postgresql-9.0.4-5.fc15.x86_64 1/1

Removed:

postgresql.x86_64 0:9 .0.4-5.fc15

Complete!

To search for all packages with a certain word

# yum search Firefox

Loaded plugins: langpacks, soon, refresh-packagekit

============== N/S Matched: Firefox ==========================

firefox.x86_64: Mozilla Firefox Web browser

gnome-do-plugins-firefox.x86_64: gnome-do-plugins for Firefox

Mozilla- firetray-firefox.x86_64: System tray extension for firefox

mozilla-adblockplus.noarch: Adblocking extension for Mozilla Firefox

mozilla-noscript.noarch: JavaScript list extension for Mozilla Firefox

Name and summary matches only, use “search all” for everything.

To obtain information about a particular package using yum:

# yum info mysql

yum info mysql

Plugins loaded: priorities, update-motd, upgrade-helper

newrelic & nbsp; & nbsp; 59/59

Installed packages

Name: mysql

Architecture & nbsp;: noarch

Version: 5.5

Release: 1.6.amzn1

Size: 0.0

Repo: installed

To view all available packages on yum repository:

# yum list

Installed packages

GeoIP.x86_64 1.4.8-1.5.amzn1 & nbsp; @amzn -main

GeoIP-Devel.x86_64 1.4.8-1.5.amzn1 @amzn -main

Pyyaml.x86_64& nbsp; 3.10-3.6.amzn1 installed

acl.x86_64 & nbsp; 2.2.49-6.9.amzn1 installed

acpid.x86_64 1.0.10-2.1.6.amzn1 installed

alsa-lib.x86_64 1.0.22-3.9.amzn1 installed

apr.x86_64 1.5.0-2.11.amzn1 @amzn -updates

(…)

To find out what package a particular file is belongs to:

# yum provides /etc/sysconfig/nfs

Plugins loaded: priorities, update-motd, upgrade-helper

1:nfs-utils-1.2.3-39.15.amzn1.x86_64: NFS utilities and supporting clients and daemons for the kernel NFS server

Repo: amzn-main

Result from:

File name: /etc/sysconfig/nfs

To find out which repositories are active in YUM:

# yum replist

repo id repo name status

amzn-main/latest AMZN-Main-Base 5.019

amzn-updates/latest AMZN-Updates-Base 1.085

newrelic/x86_64 & nbsp; New Relic packages 59

republican: 6,163

The yumdownloader command

The yumdownloader command does the downloading RPM files from the YUM repositories. It is useful for you to download the packages for later installation, or when you are going to install packages in several machines, without the need to download the same package several times.

Example:

$ yumdownloader httpd24

amzn-main/latest | 2.1 kB 00:00

amzn-updates/latest | 2.3 kB 00:00

httpd24-2.4.10-15.58.amzn1.x86_64.rpm & nbsp; | 1.3 MB 00:00