watnIn 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
To confirm the installation you have to press the Y and then ENTER.
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
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
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
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
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
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
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
To confirm the removal you have to press Y and then ENTER.
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
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
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
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
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
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
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
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
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
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
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
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
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
View History Using YUM
To see the full view of the history you can copy the following command:
sudo yum history
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
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
Here I have used this –skip-broken option while upgrading you can use it for other functions like install, and remove.
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
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
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
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:
- Adding [repository]
- 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
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
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
Now to enable this repository you can use the following command:
sudo yum-config-manager --enable docker-ce-stable
After enabling the repository, you can check whether it is enabled or not by using “repolist all”.
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
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
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.
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
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
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
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”
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’
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
If you want to update the group of packages you can copy the following command on RedHat:
sudo yum groupupdate ‘Container Management’
To confirm the download of the upgraded version you have to press Y and then ENTER.
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 dnf groupremove ‘Security Tools’
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 in a more interactive way. To run the yum shell you can copy the following command:
sudo yum 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:
After the command, you must type run and then press Enter which will start to install the package.
Users can remove, update, and search a package in the shell using the following commands:
|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]|
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.