How to Use Yum Package Manager in RHEL [A Total Guide]

LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now

In RedHat-based Linux distribution, a primary package for managing software packages is YUM which refers to the Yellowdog Updater Modifier. It facilitates the installation, updating, removal, and management of dependencies on a system.  In this article, I will discuss the yum package manager in detail.

What is YUM Package Manager in Linux?

Yum is the front-end package manager that simplifies the management including installation, upgradation, and removal easier and faster than the backend package manager rpm. The package manager uses the yum tool that helps to do the functions in a straightforward way.

The Key Components of YUM

The users who use the package manager for the first time should know about the key components of yum. Here I have shown the modules:

  • Usage: frontend system for lower-level RPM.
  • File extension: The file extension for the YUM package manager is .rpm.
  • Key Features: Installation and removal, Automated updates, dependency resolution, and repository management.
  • Dependency Handling: Check the dependencies with header files and package metadata and resolve dependencies while installing or updating packages
  • Verification tool: Build-in verification tool that ensures correct sign-in package installation.

Package Management With YUM

Managing packages means installing, removing, searching, handling a repository, and showing information about a package. Below I will illustrate the management of packages with yum.

Installing Packages With YUM

The common function of any package manager is to install a package. Yum shows variety in installation. With yum, you can install single packages, multiple packages, and packages from specific repositories. Here you can see some of the installation commands below.

1. How to Install a Single Package in RHEL

To install a single yum package you have to use the install option. Here I have used the vsftpd package You can use any package according to your liking. To practice, you can copy this command:

sudo yum install vsftpd
EXPLANATION
  • sudo: Permits administrative privileges.
  • yum: Package management system in Red Hat that provides a high-level front-end command interface.
  • install: Command install the following package.
  • vsftpd: The package that I want to install.

Install a single package with yum

To confirm the installation you have to press the Y and then ENTER.

Confirming the installation with y

After completing the installation it has been displayed in the terminal.

Showing the completion of the installation

2. Install Multiple Packages in RHEL

The user can install multiple packages using yum. You can copy the following command in RedHat.

sudo yum install firefox php postgresql
EXPLANATION
  • firefox, php, postgresql: the packages I want to install.

Install multiple packages with yum package manager

Here I have installed the packages that I needed. You can choose according to your preference.

3. How to Install a Package Locally

Sometimes users need to install a file that has already been downloaded. So to install a file locally with yum you can use the following command:

sudo yum install /home/oishi/Downloads/google-chrome-stable-116.0.5845.179-1.x86_64.rpm
EXPLANATION
  • /home/oishi/Downloads/google-chrome-stable-116.0.5845.179-1.x86_64.rpm: The path where the downloaded file is located.

Install a package locally with yum package manager

The file I have installed was already downloaded. To install the file one must use the full path where the file is located.

4. Install a Package From a Specific Repository

From a repository, you can install packages. To see all the repolist you can copy the following command:

sudo yum repolist
EXPLANATION
  • repolist: Show the current repository.

Showing the repository list with yum

Here I will install a package from the zfs repository. To install a package from a repository you can copy the following command on RedHat:

sudo yum --enablerepo=zfs install zfs --skip-broken
EXPLANATION
  • –enablerepo: Allow to enable a repository for once.
  • zfs: The repository from which I want to install a package.
  • –skip-broken: Ignore the broken dependencies while managing packages.

Install a package from repository with yum

Here I have used the –skip-broken option because it has some broken dependencies that show errors while installing.

5. Install a Specific Version of the Package in RHEL

To install a specific version of a package firstly you can use the –showduplicate option to see the available versions of the packages. Here I have used the following command to see all available versions:

sudo yum --showduplicate list httpd
EXPLANATION
  • showduplicate: Display all available versions of the package.
  • list: Shows all the packages in the system.
  • httpd: The package I want to install.

Show all the version of packages with yum

In the image, I have shown which package version I want to install.

To install a specific version of the package I have used the following command:

sudo yum install httpd-2.4.53-7.el9_1.5.x86_64
EXPLANATION
  • httpd-2.4.53-7.el9_1.5.x86_64: The specific version I want to install.

Install a specific version of package with yum

Showing the specific version of the installed package with yum

From the above image, you can see the specific version that I wanted to install has been installed. You can use any version according to your liking.

Remove Packages With YUM

Sometimes you install a package but you do not need the file later. So you can uninstall or remove it with the remove option. In this section, I have shown how to remove a single package and unnecessary packages.

1. Remove a Single Package

To uninstall a package you can use the remove option and copy the following command on RedHat:

sudo yum remove postgresql
EXPLANATION
  • remove: Remove the desired package from the repository.
  • postgresql: The package that I want to remove.

Remove a single package with yum

To confirm the removal you have to press Y and then ENTER.

Confirm the removal with y

You can choose any package to remove according to your needs.

2. Remove Multiple Packages

With yum you can remove multiple packages. Here I have shown how to remove multiple packages with one command so you can copy the following command:

sudo yum remove firefox php postgresql
EXPLANATION
  • firefox, php, postgresql: the packages I want to install.

Remove multiple packages with yum

3. Remove All Unnecessary Packages

There are many unnecessary packages installed in the system as dependencies which creates potential issues and also uses disk space. To uninstall any dependency packages that are not required by any installed packages, in Red Hat, you can copy this command:

sudo yum autoremove
EXPLANATION
  • autoremove: Uninstall any dependency that is not required by any installed packages.

Remove unnecessary files with yum

Update and Upgrade Packages With YUM

One important function of a package manager is to update the packages. With yum, you can update the full system and also single and multiple packages. Here below I have shown how to use the update command:

1. How to Check an Update

Firstly if you want to see the packages that you need to update then check the update list with the check option. It will show the list of available packages from the enabled repository. To see the list you can copy the following command:

sudo yum check-update
EXPLANATION
  • check-update: Shows the list of upgradable packages.

Check update with yum

2. How to Update All the Packages

With yum you can update and upgrade all the packages with one command. So if you want to update all the packages within one command then you can copy the following command:

sudo yum update
EXPLANATION
  • update: Command to make packages up to date.

Update all packages with yum

To confirm the installation you have to press Y and ENTER.

3. Update a Specific Package

Sometimes you need to update a specific package then use the following command:

sudo yum update httpd
EXPLANATION
  • httpd: The packages that I want to update.

Update a specific package with yum

Show the List of Packages In RHEL

Sometimes users need to know the list of packages, the list of installed packages, and whether a specific package has been installed or not. So I will show this list of packages with the yum command below:

1. How to View the Available Packages

To see all the available packages with yum you can copy the following command:

sudo yum list
EXPLANATION
  • list: Shows all the packages in the system.

Showing list of all packages with yum

With this command, you will see a huge list of packages as it shows all the installed as well as available packages.

2. How to View the List of Installed Packages

To list the all installed packages in the system you have to use the installed option with the list command:

sudo yum list installed
EXPLANATION
  • list installed: List of installed packages.

Showing the list of all installed packages with yum package manager

From the image, you can see all the packages with the rpm extension have been shown.

3. Check a Specific Package Whether It is Installed or Not

When you need to see if a specific package is installed or not then you can copy the following command:

sudo yum list installed | grep httpd
EXPLANATION
  • (|) pipe: Creates a unidirectional data channel that can be used for interprocess communication.
  • grep: Command-line for searching a file with a particular pattern.
  • httpd: The package name that I want to see.

Showing a specific package with yum package manager

Searching for Package With yum

When one needs to search for a package in the repository he can locate the package with the search command. You can copy the following command on Redhat to search for a package:

sudo yum search postgresql
EXPLANATION
  • search: Locate a package in the repository.
  • postgresql: The package that I searched for.

Search a package with yum package manager

It displays all the names that match with the package name.

Clean YUM Cache in RHEL

When you install a package, yum downloads the file and stores it in the cache directory but after deleting the package this is not removed from the cache directory. So below I have shown how to clean the files.

1. How to Clean the Cache Packages

To clean all the cache packages use the following command:

sudo yum clean packages
EXPLANATION
  • yum: Package management system in Red Hat that provides a high-level front-end command interface.
  • clean: Command to clean all the cached files.
  • packages: Purge the cached packages.

Remove all packages with yum package

It will remove all the cache packages from the enabled directory.

2. How to Clean the Cache Header

When you update the local cache it includes the header in the /var/cache/yum directory. To remove the cached headers, you can copy the following command:

sudo yum clean headers
EXPLANATION
  • headers: Purge the cached headers.

Remove cache header with yum package manager

3. How to Clean the Cache Metadata

If you want to purge all the metadata that is included while transaction of the system you can delete them with the following command:

sudo yum clean metadata
EXPLANATION
  • metadata: Purge the cached metadata.

Remove cache metadata with yum package manager

4. How to Clean All the Cache Files

To purge all the cache files with one single command you can use the following command:

sudo yum clean all
EXPLANATION
  • clean all: Purge all the cached files at a time.

Remove all the cache files with yum

View History Using YUM

To see the full view of the history you can copy the following command:

sudo yum history
EXPLANATION
  • history: Displays all the yum transactions.

View the history with yum package manager

With this command you can able to see what transactions have you done.

Use YUM Plugins

Yum supports plugins that increase functionality, extensibility, and customization of the software. If you want to see the plugins that your system has then you can use the following command:

sudo yum list installed | grep plugin
EXPLANATION
  • list installed: List of installed packages.
  • (|)pipe: Creates a unidirectional data channel that can be used for interprocess communication.
  • grep: Command-line for searching a file with a particular pattern.
  • plugin: Software component that I searched for.

Plugin with yum

This will show you all the plugin that is available in your system. If you want to add additional plugins then you have to install the specific plugin as package installation.

Skip Broken Dependencies in RHEL

Sometimes while transitioning, because of the broken or unsolved dependencies that particular function does not work. But with the –skip-broken option user can skip that dependency and successfully perform the transaction. If you want to skip the unsolved or broken dependencies you can copy the following command:

sudo yum -y upgrade --skip-broken
EXPLANATION
  • -y option: This option indicates yes to all the confirmations.
  • Upgrade: Upgrade to the newer version.
  • –skip-broken: Skip the broken dependencies while the transaction.

Skipping the broken dependencies with yum

Here I have used this –skip-broken option while upgrading you can use it for other functions like install, and remove.

YUM Downgrade

If one upgraded package shows an error or is not needed anymore then you can downgrade the package with the following command:

sudo yum downgrade php-8.0.20-3.el9
EXPLANATION
  • downgrade: Revert a package to an older version.

Downgrade a package with yum

From the image, you can see the older version of the package is installed.

Management of Repositories With YUM

You can handle repositories with Yum. First I want to see the repository list. To display the repository list you can copy the command:

sudo yum repolist
EXPLANATION
  • repolist: Show the current repository.

Showing the repository list with yum

Add a Repository

You need the yum-utils package to add the repository. So, if there is no installed yum-utils package, firstly you have to install the package. To install the package you can copy this command:

sudo yum install yum-utils
EXPLANATION
  • yum-utils: The package that I want to install which includes many tools and utilities.

Installing yum-utils with yum

In the command, you can use the -y option which indicates yes to all yum-utils packages which will not show any confirmation.

You can add a new repository by two methods:

  1. Adding [repository]
  2. Adding repo file

As, you know the yum repositories provide their own repo file so I will add the repository, and yum will add the repo file to the directory. You can copy this syntax to add a repository:

sudo yum-config-manager \

--add-repo \

https://download.docker.com/linux/centos/docker-ce.repo
EXPLANATION
  • config-manager: Works on the configuration of the repository.
  • –add-repo: Add the following url repository to the current repository.
  • https://download.docker.com/linux/centos/docker-ce.repo: The Repository url which I want to add.

Added new repository with yum

From the image you can see the new repository has been added.

List All Enabled and Disabled Yum Repositories

If you use “repolist all” then you can be able to see the enabled and disabled repositories. Copy the following command on Redhat to see the enabled and disabled repositories.

sudo yum repolist all
EXPLANATION
  • repolist all: Show the current repo list with enabled and disabled repositories.

Command for all repository list with yum

Showing the enabled and disabled package list with yum

So with this command, you will be able to see the enabled and disabled repositories.

Enable a Repository

First to enable a repository one must know which package is disabled to see the package status you can use the following command:

sudo yum repolist all

Showing the disabled repository with yum

Now to enable this repository you can use the following command:

sudo yum-config-manager --enable docker-ce-stable
EXPLANATION
  • –enabled: This option will enable the following repository.
  • docker-ce-stable: The repository I want to enable.

Enabling a repository with yum

After enabling the repository, you can check whether it is enabled or not by using “repolist all”.

Showing the enabled repository with yum

And you can see that the repository has been enabled.

Disable a Repository

Firstly to disable a repository, I will see the repository list. To display the repository list you can copy this command:

sudo yum repolist all

Disable this repository with yum

From the image, you can see I want to disable the repository that I enabled before.

So, To disable the repository from the directory you can copy the command:

sudo yum-config-manager --disable docker-ce-stable
EXPLANATION
  • –disable: This option will disable the following repository.
  • docker-ce-stable: The repository I want to disable.

Disabling the repository with yum

After disabling the repository I want to see if it has been disabled or not. To see that I have used the “repolist all” command.

Repository has been disabled with yum

From the above image, you can see the repository has been disabled.

YUM Provides Function

If you want to see a specific file belongs to which package then you can use the following command:

sudo yum provides /etc/httpd/conf/httpd.conf
EXPLANATION
  • provide: Displays which packages a file owns.
  • /etc/httpd/conf/httpd.conf: The path of the file that I want to know.

Find which package provide a file with yum

Manage Package Group With YUM

If you can install, or remove a package group then it is easy and efficient to manage the system as with a single command you can install the whole software group. Below I have shown how to manage a software group.

1. List All Available Group Packages

If you want to see all the available software groups then you can copy the following command:

sudo yum grouplist
EXPLANATION
  • grouplist: Display all the available and installed group list.

Displays grouplist with yum

You can see all the available environments, groups and install environments and groups.

2. List All Packages in a Group

If you want to see the packages in a software group you can do this with yum. Firstly I have shown which group I want to see. For that, you have to use the following command:

sudo yum grouplist

Showing which group install with yum

Here I want to see the packages inside the security tools group. So for that, I have used the following command:

sudo yum groupinfo "Security Tools"
EXPLANATION
  • groupinfo: Show the information of a group of packages.
  • Security Tools: A group of packages.

Info of a group of software package with yum

From the image, you can see there are default and optional packages inside the Security Tools group.

3. Install Group Packages

Installing a group of packages with a single command has solved many problems if you want to install the items in the system tools group then you have to install many libraries and packages which is very difficult. But with the group option, you can install them with a single command:

sudo yum groupinstall 'SecurityTools'
EXPLANATION
  • groupinstall: Install the following group of packages.
  • Security Tools: The group of packages that I want to install.

Install a group of packages with yum

4. Update Group Packages

To update a group of packages you can use the groupupdate option that upgrades all the packages that are available in a group.

sudo yum grouplist
EXPLANATION
  • grouplist: Display all the available and installed group list.

Update the group of packages with yum

If you want to update the group of packages you can copy the following command on RedHat:

sudo yum groupupdate 'Container Management'
EXPLANATION
  • Groupupdate: Command to up to date a group of package.

Update container group with yum

Confirmation of update

To confirm the download of the upgraded version you have to press Y and then ENTER.

Complete the update of group

After the upgrade, in the terminal, there has been shown the complete text.

5. Remove a Group of Packages

If you want to remove or uninstall a group of packages then you can copy the following command:

sudo yum groupremove 'Security Tools'
EXPLANATION
  • groupremove: Remove the following group of packages.
  • System Tools: The group of packages that I want to remove.

Remove a group of packages with yum

So, in yum by using the group option you can install and remove a group of packages easily.

Interactive Yum Shell

Yum provides an interactive shell that helps one to install, and remove update packages more interactively. To run the yum shell you can copy the following command:

sudo yum shell
EXPLANATION
  • shell: Interactive environment and use yum commands.

Yum interactive shell

Here in the shell, I have used the repolist option and then press ENTER. So, it shows the repolist of the system.

If you want to install a package in the shell you can use the command inside the shell:

install firefox

After the command, you must type run and then press Enter which will start to install the package.

Install package with yum in shell

Users can remove, update, and search a package in the shell using the following commands:

Functions Shell Command
Install a package install [package name] + run
Uninstall a package remove [pacakge name] +run
Update the package update [package name] +run
Search or locate a package search [package name]

Conclusion

The article mainly describes the process of managing a package with the yum package manager. From the article, the beginner will get to know about the commands and be able to know how to use yum tools. I have tried to make the managing process simple and hope after reading the article one will be able to manage yum package manager easily.

People Also Ask

What is the difference between RPM and Yum?
As these two package managers are used in the RedHat-based Linux distribution but RPM is the lower-level package manager that is used in the backend of Yum. So the main difference is one of them is used for the front-end and the other is used for the back-end.

How do I install apt get yum?
No, you can not install apt(apt-get) through yum and vice versa. Because both of them are used for different distributions and work with different file extensions.

Why is it better to use apt rather than yum?
I don’t think apt is better than yum because you have to use them in different distributions. While installing in Linux distribution, a package manager is installed by default. So apt is better for Debian-based distribution but not better than yum.

Related Articles


<< Go Back to Package Manager Examples | Package Management in Linux | Learn Linux Basics

5/5 - (8 votes)
Afia Zahin Oishi

Assalamualaikum, I am Afia Zahin, completed my graduation in Biomedical Engineering from Bangladesh University of Engineering and Technology, currently working as a Linux Content Developer Executive at SOFTEKO. A high achieving professional with a strong work ethic and able to work in a team in order to consistently achieve my goal and build my skillset. Able to handle difficult problems with patience and swift decision-making. Read Full Bio

Leave a Comment