Linux Package Management in Red Hat-Based Distributions #
Installing, patching, and removing software packages on Linux machines is one of the common tasks every sysadmin has to do. Here is how to get started with Linux package management in Linux Red Hat-based distributions (distros).
What is Package Management? #
Package management is a method of installing, updating, removing, and keeping track of software updates from specific repositories (repos) in the Linux system. Linux distros often use different package management tools. Red Hat-based distros use RPM (RPM Package Manager) and YUM/DNF (Yellow Dog Updater, Modified/Dandified YUM).
Yellow Dog Updater, Modified (YUM) #
Note: DNF or Dandified YUM is the updated default since Red Hat Enterprise Linux 8, CentOS 8, Fedora 22, and any distros based on these. Generally, the options are the same. Read more about DNF here.
YUM is the primary package management tool for installing, updating, removing, and managing software packages in Red Hat Enterprise Linux. YUM performs dependency resolution when installing, updating, and removing software packages. It can manage packages from installed repositories in the system or from .rpm
packages.
- Main configuration file:
/etc/yum.conf
- Repositories:
/etc/yum.repos.d
Basic YUM Command Syntax #
yum -option command
Commonly-Used YUM Commands #
Command | Purpose |
---|---|
yum install |
Installs the specified packages |
yum remove |
Removes the specified packages |
yum search |
Searches package metadata for keywords |
yum info |
Lists package description |
yum update |
Updates each package to the latest version |
yum repolist |
Lists repositories |
yum history |
Displays past transactions |
Commonly-Used YUM Options #
Option | Purpose |
---|---|
-C |
Runs from system cache |
--security |
Includes packages that provide a security fix |
-y |
Answers ‘yes’ to all questions |
--skip-broken |
Skips problematic packages |
-v |
Verbose output |
Managing History with YUM #
The history
option provides an overview of past transactions:
yum history
You can undo or redo transactions using:
yum history undo <id>
For more detailed option information, refer to:
man yum
yum --help
- YUM documentation
RPM (RPM Package Manager) #
RPM is a popular package management tool in Red Hat Enterprise Linux-based distros. It allows installing, uninstalling, and querying individual software packages but does not handle dependency resolution like YUM.
RPM Package Structure #
An RPM package consists of:
- An archive of files
- Metadata including helper scripts, file attributes, and package information
RPM Database #
- Location:
/var/lib
- File:
__db*
Basic RPM Command Syntax #
rpm -mode options package-file
Commonly-Used RPM Modes #
Mode | Description |
---|---|
-i |
Installs a package |
-U |
Upgrades a package |
-e |
Erases a package |
-V |
Verifies a package |
-q |
Queries a package |
Commonly-Used RPM Options #
Option | Purpose |
---|---|
`-? | –help` |
--version |
Prints version number |
-v |
Prints verbose output |
Installing and Upgrading Packages #
rpm -i package-file # Install a package
rpm -U package-file # Upgrade a package
rpm -ivh package-file # Install with verbose and hash progress
-i
: Install-U
: Upgrade-v
: Verbose-h
: Hash progress bar
Querying Packages #
rpm -q query-options package
rpm -qa vim-enhanced # Queries all installed packages
Erasing Packages #
rpm -e erase-options package-name
rpm -evh vim-enhanced
Wrap Up #
Package management is a common task for every system. YUM and RPM provide efficient ways to install, upgrade, remove, and track software packages on Red Hat Enterprise Linux systems.