FUNDAMENTALS A Complete Guide for Beginners
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
To confirm the installation you have to press the Y and then ENTER.
After completing the installation it has been displayed in the terminal.
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
- firefox, php, postgresql: the packages I want to install.
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
- /home/oishi/Downloads/google-chrome-stable-116.0.5845.179-1.x86_64.rpm: The path where the downloaded file is located.
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
- repolist: Show the current repository.
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
- –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.
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
- showduplicate: Display all available versions of the package.
- list: Shows all the packages in the system.
- httpd: The package I want to install.
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
- httpd-2.4.53-7.el9_1.5.x86_64: The specific version I want to install.
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
- remove: Remove the desired package from the repository.
- postgresql: The package that I want to remove.
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
- firefox, php, postgresql: the packages I want to install.
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
- autoremove: Uninstall any dependency that is not required by any installed packages.
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
- check-update: Shows the list of upgradable packages.
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
- update: Command to make packages up to date.
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
- httpd: The packages that I want to update.
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
- list: Shows all the packages in the system.
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
- list installed: List of installed packages.
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
- search: Locate a package in the repository.
- postgresql: The package that I searched for.
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
- 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.
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
- headers: Purge the cached 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
- metadata: Purge the cached 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
- clean all: Purge all the cached files at a time.
View History Using YUM
To see the full view of the history you can copy the following command:
sudo yum history
- history: Displays all the yum transactions.
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
- 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.
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
- -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.
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
- downgrade: Revert a package to an older version.
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
- repolist: Show the current repository.
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
- yum-utils: The package that I want to install which includes many tools and utilities.
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
- 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.
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
- repolist all: Show the current repo list with enabled and disabled repositories.
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
- –enabled: This option will enable the following repository.
- docker-ce-stable: The repository I want to enable.
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
- –disable: This option will disable the following repository.
- docker-ce-stable: The repository I want to disable.
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
- provide: Displays which packages a file owns.
- /etc/httpd/conf/httpd.conf: The path of the file that I want to know.
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
- grouplist: Display all the available and installed group list.
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"
- groupinfo: Show the information of a group of packages.
- Security Tools: A group of packages.
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'
- groupinstall: Install the following group of packages.
- Security Tools: The group of packages that I want to install.
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
- grouplist: Display all the available and installed group list.
If you want to update the group of packages you can copy the following command on RedHat:
sudo yum groupupdate 'Container Management'
- Groupupdate: Command to up to date a group of package.
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 yum groupremove 'Security Tools'
- groupremove: Remove the following group of packages.
- System Tools: The group of packages that I want to remove.
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
- shell: Interactive environment and use yum commands.
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.
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
Related Articles
- How to Use DNF Package Manager in Linux [A Complete Guide]
- A Total Guide on RPM Package Manager in Linux
- Apt Package Manager [A Complete Guide on How to Use it]
- The Synaptic Package Manager [A Complete Guide]
- Pacman Package Manager in Linux [How to Use It]
<< Go Back to Package Manager Examples | Package Management in Linux | Learn Linux Basics