Linux yum Command with Practical Examples

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, we will explore the yum package manager, a powerful tool for managing software packages on Red Hat-based Linux distributions. We will learn how to install, update, and remove packages using yum, as well as search for available packages and check for updates.

First, we will introduce the yum package manager, its key features, and check the current version installed on our system. Then, we will demonstrate how to install new packages, update existing ones, and remove packages using various yum commands. This lab provides practical examples and step-by-step guidance to help you become proficient in managing packages on your Linux system.

Linux Commands Cheat Sheet


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/PackagesandSoftwaresGroup(["`Packages and Softwares`"]) linux/PackagesandSoftwaresGroup -.-> linux/software("`Linux Software`") subgraph Lab Skills linux/software -.-> lab-423016{{"`Linux yum Command with Practical Examples`"}} end

Introduction to yum Package Manager

In this step, we will explore the yum package manager, which is a powerful tool for managing software packages on Red Hat-based Linux distributions, including CentOS, Fedora, and RHEL.

First, let's check the current version of yum installed on our system:

yum --version

Example output:

4.4.2

The yum package manager provides several key features:

  1. Installing Packages: You can use yum to install new software packages on your system.
  2. Updating Packages: yum can be used to update installed packages to their latest versions.
  3. Removing Packages: Packages can be removed using the yum command.
  4. Searching for Packages: You can search for available packages using yum.
  5. Checking for Package Updates: yum can check for and notify you of available package updates.

Now, let's try some basic yum commands to get a better understanding of how it works.

Installing Packages Using yum

In this step, we will learn how to install new packages using the yum package manager.

First, let's search for a package we want to install. For 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 shows that the "tree" package is available. Now, let's install it:

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 downloads and installs the specified package, along with any required dependencies.

Let's verify that the "tree" package is now installed:

tree --version

Example output:

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

Great! We have successfully installed the "tree" package using yum.

Updating and Removing Packages with yum

In this step, we will learn how to update and remove packages using the yum package manager.

First, let's check for any available updates for the packages installed on our system:

sudo yum check-update

Example output:

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

The output shows that there are no available updates for the installed packages.

Now, let's update a specific package. We'll use the "tree" package as an 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 updates the specified package to the latest available version.

Finally, let's remove 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 removes the specified package from the system.

Summary

In this lab, we explored the yum package manager, a powerful tool for managing software packages on Red Hat-based Linux distributions. We learned how to check the current version of yum installed on our system, and the key features of the yum package manager, including installing, updating, and removing packages, as well as searching for and checking for available package updates. We then practiced installing a new package, the "tree" package, using the yum command.

Linux Commands Cheat Sheet

Other Linux Tutorials you may like