yum Command in Linux

Introduction to Yum Package Management

This lab provides a comprehensive guide to the yum package manager, a vital tool for system administrators on Red Hat-based Linux systems. Learn how to effectively manage software packages, including installation, updates, and removal. This tutorial will also cover searching for packages and checking for available updates, empowering you to maintain a secure and up-to-date system.

We'll start with an introduction to yum, covering its core features and how to verify the installed version. Then, we'll delve into practical demonstrations of installing, updating, and removing packages using various yum commands. This hands-on lab will equip you with the skills to confidently manage packages on your Linux server.

Understanding the yum Package Manager

In this section, we will examine the yum package manager, a cornerstone of software management on Red Hat-derived Linux distributions such as CentOS, Fedora, and RHEL. Systemadmin proficiency often relies on understanding yum.

First, let's determine the yum version currently installed:

yum --version

Example output:

4.4.2

The yum package manager boasts a number of essential capabilities:

  1. Package Installation: Install new software packages seamlessly using yum.
  2. Package Updates: Keep your system secure by updating installed packages to the latest versions via yum.
  3. Package Removal: Remove unwanted or outdated packages with the yum remove command.
  4. Package Searching: Find available packages that meet your needs by searching the repositories.
  5. Update Checks: Regularly check for available updates to maintain system stability and security.

Let's explore some fundamental yum commands to gain a better grasp of its functionality.

Package Installation with yum

This section focuses on installing new packages using the yum package manager. Proper systemadmin practice includes mastering package installation.

First, let's locate a package we wish to install. In this example, we'll search for the "tree" package:

yum search tree

Example output:

Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
============================== N/S Matched: tree ===============================
tree.x86_64 : Display a directory tree, in color

The output confirms the "tree" package is available. Now, let's proceed with its installation:

sudo yum install -y tree

Example output:

Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.8.0-10.el8 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
 Package        Arch           Version                 Repository      Size
=============================================================================
Installing:
 tree           x86_64         1.8.0-10.el8            AppStream       55 k

Transaction Summary
=============================================================================
Install  1 Package

Total download size: 55 k
Installed size: 94 k
Downloading Packages:
tree-1.8.0-10.el8.x86_64.rpm                         55 kB/s | 55 kB     00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Preparing        :                                                    1/1
  Installing       : tree-1.8.0-10.el8.x86_64                           1/1
  Verifying        : tree-1.8.0-10.el8.x86_64                           1/1

Installed:
  tree-1.8.0-10.el8.x86_64

Complete!

The yum install command automatically handles downloading and installing the specified package, along with any necessary dependencies.

To verify the successful installation of the "tree" package, execute:

tree --version

Example output:

tree v1.8.0 (c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro

Excellent! We have successfully installed the "tree" package using yum. Root access is not explicitly required for simply querying the version.

Package Updates and Removal with yum

This section explores updating and removing packages using the yum package manager. Crucial skills for any systemadmin.

First, let's check if there are any updates available for our installed packages:

sudo yum check-update

Example output:

Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
There are no packages to update

The output indicates that no updates are currently available.

Next, let's update a specific package. We will use the "tree" package as our example:

sudo yum update tree

Example output:

Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.8.0-10.el8 will be updated
---> Package tree.x86_64 0:1.8.0-12.el8 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
 Package        Arch           Version                 Repository      Size
=============================================================================
Updating:
 tree           x86_64         1.8.0-12.el8            AppStream       55 k

Transaction Summary
=============================================================================
Upgrade  1 Package

Total download size: 55 k
Downloading Packages:
tree-1.8.0-12.el8.x86_64.rpm                         55 kB/s | 55 kB     00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Preparing        :                                                    1/1
  Updating         : tree-1.8.0-12.el8.x86_64                           1/1
  Cleanup          : tree-1.8.0-10.el8.x86_64                           1/1
  Verifying        : tree-1.8.0-12.el8.x86_64                           1/1

Updated:
  tree-1.8.0-12.el8.x86_64

Complete!

The yum update command ensures the specified package is updated to the most recent version available.

Finally, let's demonstrate removing the "tree" package:

sudo yum remove tree

Example output:

Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.8.0-12.el8 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
 Package        Arch           Version                 Repository      Size
=============================================================================
Removing:
 tree           x86_64         1.8.0-12.el8            @AppStream      55 k

Transaction Summary
=============================================================================
Remove  1 Package

Installed size: 94 k
Downloading Packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Preparing        :                                                    1/1
  Erasing          : tree-1.8.0-12.el8.x86_64                           1/1
  Verifying        : tree-1.8.0-12.el8.x86_64                           1/1

Removed:
  tree-1.8.0-12.el8.x86_64

Complete!

The yum remove command uninstalls the specified package from the Linux system.

yum Package Manager: Key Takeaways

This lab provided a hands-on exploration of the yum package manager, a critical tool for system administration on Red Hat-based Linux distributions. We covered verifying the installed yum version, understanding core features such as package installation, updates, and removal, and searching for and checking for available updates. The lab then guided you through installing the "tree" package using the yum command, solidifying your understanding of package management in Linux environments.

400+ Linux Commands