RPM and YUM Software Lifecycle on CentOS

Binary application components — executables, libraries, configurations, and documentation — are bundled into package files so they can be installed, upgraded, queried, and removed consistently. On RPM‑based distributions the native low‑level tool is rpm; higher‑level tools such as yum (and its successor dnf) add automatic dependancy resolution and repository awareness.

RPM Package Naming

A typical package file follows the pattern:

name-VERSION-release.architecture.rpm
  • VERSION uses major.minor.release numbering.
  • release carries the package iteration and optional OS tag, e.g. 2.el7.
  • architecture may be i386, x86_64, ppc, or noarch.

Main packages supply the core functionality; companion sub‑packages extend it with headers, shared libraries, or utilities and adopt the form name-function-VERSION-release.arch.rpm.

RPM Database and Package Integrity

Installed package metadata lives under /var/lib/rpm/. Every transaction records file lists, checksums, dependency mappings, and the embedded scriptlets that may run before or after install (%pre, %post) and erase (%preun, %postun).

To verify a package’s origin and digest, import the distribution GPG key:

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Manual verification of a local .rpm file:

rpm -K nginx-1.20.1-1.el7.x86_64.rpm

Common rpm Operations

Install

rpm -ivh package.rpm          # verbose, hash progress
rpm -ivh --test package.rpm   # dry‑run, report conflicts
rpm -ivh --nodeps package.rpm # skip dependency checks (use with care)

Upgrade & Freshen

rpm -Uvh package.rpm   # upgrade or install if absent
rpm -Fvh package.rpm   # upgrade only if already installed

New configuration files from a upgrade are saved as *.rpmnew instead of overwriting existing modified configs.

Erase

rpm -e package_name
rpm -e --test package_name   # simulate removal

Query installed and uninstalled packages

rpm -qa                              # all installed packages
rpm -qf /usr/bin/curl                # which package owns this file
rpm -ql curl                         # files owned by curl
rpm -qi curl                         # detailed package information
rpm -qc curl                         # configuration files only
rpm -qd curl                         # documentation files only
rpm -qR curl                         # dependencies
rpm -q --scripts curl                # embedded scriptlets

# Inspect an uninstalled .rpm file
rpm -qpl nginx-1.20.1-1.el7.x86_64.rpm   # file list
rpm -qpi nginx-1.20.1-1.el7.x86_64.rpm   # info

Verification of installed files
The -V flag compares on‑disk files against the database:

rpm -Va   # verify every installed package

Flag characters indicate mismatches: S size, M mode/permissions, 5 digest, L symlink path, U user, G group, T mtime.

Rebuild or initialise the database

rpm --rebuilddb   # scan installed packages and recreate /var/lib/rpm
rpm --initdb      # create empty database

YUM – Repository‑Aware Package Management

YUM (Yellowdog Updater, Modified) overlays rpm with dependency solving, group operations, and remote repository fetching.

Repository definition
Global defaults live in /etc/yum.conf; individual repo files are placed in /etc/yum.repos.d/ with the .repo suffix. A minimal entry:

[my-repo]
name = Custom Repository
baseurl = http://repo.example.com/centos/7/x86_64/
enabled = 1
gpgcheck = 1
gpgkey = http://repo.example.com/RPM-GPG-KEY-custom

The baseurl must point to a directory that contains a repodata/ sub‑directory. Supported protocols include http, https, ftp, file, and nfs.

Frequent commands

yum repolist all                     # list enabled and disabled repos
yum makecache                         # download metadata to speed future queries
yum list available                    # show packages available for install
yum search keyword                    # search name and summary
yum info package                      # detailed package description
yum provides /path/to/file            # find which package supplies a file
yum deplist package                   # dependency tree

# Installing, updating, removing
yum install package
yum update package
yum upgrade                            # update with obsoletes
yum remove package

# Group operations
yum grouplist
yum groupinstall "Development Tools"
yum groupremove "Web Server"

# Transaction history
yum history list
yum history undo 5
yum history redo 5

# Local RPM installation (deprecated — prefer install)
yum localinstall /tmp/package.rpm

Building a local repository
Mount an ISO, then use createrepo:

mount -o loop CentOS-7-x86_64-DVD.iso /mnt/cdrom
createrepo /mnt/cdrom

Now point a .repo file’s baseurl to file:///mnt/cdrom.

Command‑line modifiers

  • -y auto‑confirm prompts
  • -q silent mode
  • --nogpgcheck disable signature verification
  • --enablerepo=id / --disablerepo=id temporarily override repo states

Compiling from Source

When packages are unavailable, source tarballs are built with:

tar xf app-1.2.3.tar.gz
cd app-1.2.3
./configure --prefix=/usr/local/app
test $? -eq 0 && make
test $? -eq 0 && sudo make install

./configure inspects the system, honours --enable-*/--with-* switches, and creates Makefile from Makefile.in. After installation, register paths so the system finds the software:

# 1. Binary — add to shell profile
echo 'export PATH=/usr/local/app/bin:$PATH' > /etc/profile.d/app.sh

# 2. Library — register directory and update linker cache
echo '/usr/local/app/lib' > /etc/ld.so.conf.d/app.conf
sudo ldconfig -v

# 3. Headers — symlink into default include path
ln -sv /usr/local/app/include /usr/include/app

# 4. Man pages — adjust MANPATH in /etc/man_db.conf or /etc/man.config

Build‑essential toolchains (gcc, make, autoconf, automake) and standard libray headers (glibc-devel) are typically supplied through group packages such as "Development Tools".

Tags: Linux rpm Yum Package Management centos

Posted on Fri, 30 Oct 2026 16:14:05 +0000 by slaeya