Linux package management with YUM and RPM (2024)

Posted: April 22, 2020 | | by Keerthi Chinthaguntla (Sudoer alumni)

Image

Linux package management with YUM and RPM (1)

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).

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)

[ Editor's Note: DNF or Dandified YUM is the updated defaultsince 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. YUM can manage packages from installed repositories in the system or from .rpm packages. The main configuration file for YUM is at /etc/yum.conf, and all the repos are at /etc/yum.repos.d.

[ Read: A quick guide to DNF for yum users ]

You can learn more about adding repositories to your system from this article on how to add a YUM repo from Amy Marrich.

It's easy to manage packages in Linux with YUM. At the command line, enter:

yum -option command

There are many options and commands available to use with YUM. I've listed some commonly-used commands for YUM below:

CommandPurpose
yum installInstalls the specified packages
removeRemoves the specified packages
searchSearches package metadata for keywords
infoLists description
updateUpdates each package to the latest version
repolistLists repositories
historyDisplays what has happened in past transactions

The following are commonly-used options with YUM:

OptionsPurpose
-CRuns from system cache
--securityIncludes packages that provide a fix for a security issue
-yAnswers yes to all questions
--skip-brokenSkips packages causing problems
-vVerbose

The history option gives you an overview of what happened in past transactions. This provides some useful information, like the date when the transaction happened and what command was run.

Image

Linux package management with YUM and RPM (2)

You can undo or redo certain transactions using the history command. Here is an example of undoing a transaction:

yum history undo <id>

YUM provides many options for package management. For detailed option information, look at man yum and yum –help. Also, here is a link to YUM documentation.

RPM (RPM Package Manager)

RPM is a popular package management tool in Red Hat Enterprise Linux-based distros. Using RPM, you can install, uninstall, and query individual software packages. Still, it cannot manage dependency resolution like YUM. RPM does provide you useful output, including a list of required packages. An RPM package consists of an archive of files and metadata. Metadata includes helper scripts, file attributes, and information about packages.

RPM maintains a database of installed packages, which enables powerful and fast queries. The RPM database is inside /var/lib, and the file is named __db*.

RPM has some basic modes: query, verify, install, upgrade, erase, show querytags, show configuration. At least one of these modes needs to be selected to perform package management tasks. Every mode has its own set of options. For example, install mode i has its own set of installation options. Options for the modes are found on the RPM man pages at man rpm.

Some commonly-used modes are listed below:

ModeDescription
-iInstalls a package
-UUpgrades a package
-eErases a package
-VVerifies a package
-qQueries a package

Here are some commonly-used general options:

General optionsPurpose
-? | --helpPrints help
--versionPrints version number
-vPrints verbose output

To install or upgrade an .rpm package using RPM, issue this command:

rpm -i package-file

rpm -U package-file

rpm -ivh package-file

The flag -i is for install, U is for upgrade, v for verbose, h for hash (this option displays the # as a progress bar for the operation). In this example, v and h are optional flags.

To query for a package using RPM issue following command:

rpm -q query-options package

rpm -qa vim-enhanced

Option a queries all installed packages on the system.

Image

Linux package management with YUM and RPM (4)

To erase a package, use the following command:

rpm -e erase-options package-name

rpm -evh vim-enhanced

Image

Linux package management with YUM and RPM (5)

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.

[ Want to try out Red Hat Enterprise Linux? Download it now for free. ]

As an enthusiast and expert in Linux system administration, I bring a wealth of practical knowledge and experience to the table. Having worked extensively with Linux Red Hat-based distributions, I've mastered the intricacies of package management using RPM (RPM Package Manager) and YUM/DNF (Yellow Dog Updater, Modified/Dandified YUM).

Let's delve into the concepts discussed in the article:

Package Management in Linux Red Hat-based Distributions

1. Package Management Overview:

  • Package management involves installing, updating, removing, and tracking software updates from specific repositories in the Linux system.
  • Different Linux distributions use various package management tools.

2. YUM (Yellow Dog Updater, Modified):

  • YUM is the primary package management tool for Red Hat Enterprise Linux.
  • Performs dependency resolution during package installation, updating, and removal.
  • Key files: /etc/yum.conf (main configuration) and /etc/yum.repos.d (repository configurations).

3. YUM Commands:

  • Commonly used YUM commands:

    • yum install: Installs specified packages.
    • yum remove: Removes specified packages.
    • yum search: Searches package metadata for keywords.
    • yum info: Lists package descriptions.
    • yum update: Updates each package to the latest version.
    • yum repolist: Lists repositories.
    • yum history: Displays past transactions.
  • Commonly used YUM options:

    • -C: Runs from system cache.
    • --security: Includes packages that fix security issues.
    • -y: Answers yes to all questions.
    • --skip-broken: Skips packages causing problems.
    • -v: Verbose output.
  • History command usage:

    • yum history undo <id>: Undo a specific transaction.

4. RPM (RPM Package Manager):

  • RPM is a popular package management tool in Red Hat Enterprise Linux-based distros.
  • Manages individual software packages but lacks dependency resolution (contrasted with YUM).
  • RPM package consists of files and metadata, including helper scripts and package information.
  • Maintains a database of installed packages in /var/lib.

5. RPM Commands:

  • Commonly used RPM modes:

    • -i: Installs a package.
    • -U: Upgrades a package.
    • -e: Erases a package.
    • -V: Verifies a package.
    • -q: Queries a package.
  • General RPM options:

    • --help: Prints help.
    • --version: Prints version number.
    • -v: Prints verbose output.
  • Examples of RPM commands:

    • rpm -i package-file: Installs an RPM package.
    • rpm -U package-file: Upgrades an RPM package.
    • rpm -q query-options package: Queries information about a package.
    • rpm -e erase-options package-name: Erases a package.

6. Package Management Conclusion:

  • Concludes by emphasizing that package management is a common task for system administrators, and YUM and RPM provide efficient ways to handle it.

In summary, mastering YUM and RPM is crucial for effective Linux system administration, particularly in Red Hat-based distributions. These tools empower administrators to seamlessly install, update, remove, and manage software packages while efficiently handling dependencies.

Linux package management with YUM and RPM (2024)
Top Articles
Latest Posts
Article information

Author: Stevie Stamm

Last Updated:

Views: 5595

Rating: 5 / 5 (80 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Stevie Stamm

Birthday: 1996-06-22

Address: Apt. 419 4200 Sipes Estate, East Delmerview, WY 05617

Phone: +342332224300

Job: Future Advertising Analyst

Hobby: Leather crafting, Puzzles, Leather crafting, scrapbook, Urban exploration, Cabaret, Skateboarding

Introduction: My name is Stevie Stamm, I am a colorful, sparkling, splendid, vast, open, hilarious, tender person who loves writing and wants to share my knowledge and understanding with you.