Introduction
YUM is the package manager for RHEL 7 and below operating systems. This article covers how to use YUM to manage to packages installed on your server. Note that while RHEL 8 based operating systems use DNF as the package manager, they also include a wrapper that allows YUM commands to still work.
Procedure
Searching for a package by name or description
You can search for a package with the command below, where TEXT is replaced with what you're searching for.
yum search TEXT
For example, if you'd like to search for the Intl PHP extension.
[root@server ~]# yum search intl
Loaded plugins: fastestmirror, universal-hooks
Loading mirror speeds from cached hostfile
* EA4: 184.94.196.93
* cpanel-addons-production-feed: 184.94.196.93
* cpanel-plugins: 184.94.196.93
========================================================================================================================== N/S matched: intl ==========================================================================================================================
ea-php54-php-intl.x86_64 : Internationalization extension for PHP applications
ea-php55-php-intl.x86_64 : Internationalization extension for PHP applications
ea-php56-php-intl.x86_64 : Internationalization extension for PHP applications
ea-php70-php-intl.x86_64 : Internationalization extension for PHP applications
ea-php71-php-intl.x86_64 : Internationalization extension for PHP applications
ea-php72-php-intl.x86_64 : Internationalization extension for PHP applications
ea-php73-php-intl.x86_64 : Internationalization extension for PHP applications
ea-php74-php-intl.x86_64 : Internationalization extension for PHP applications
intltool.noarch : Utility for internationalizing various kinds of data files
perl-libintl.x86_64 : Internationalization library for Perl, compatible with gettext
Name and summary matches only, use "search all" for everything.
Searching for a package by contents
Sometimes you may not know much about a package except that it contains a specific file. In this case, you can use the command below, where /PATH/TO/FILE is replaced with the actual path to the file.
yum provides /PATH/TO/FILE
For example, if we want to search for the package containing /opt/cpanel/ea-php74/root/usr/lib64/php/modules/intl.so.
[root@server ~] # yum provides /opt/cpanel/ea-php74/root/usr/lib64/php/modules/intl.so
Loaded plugins: fastestmirror, universal-hooks
Loading mirror speeds from cached hostfile
* EA4: 184.94.196.93
* cpanel-addons-production-feed: 184.94.196.93
* cpanel-plugins: 184.94.196.93
ea-php74-php-intl-7.4.9-1.1.7.cpanel.x86_64 : Internationalization extension for PHP applications
Repo : EA4
Matched from:
Filename : /opt/cpanel/ea-php74/root/usr/lib64/php/modules/intl.so
...
Searching for historical install information about a package
You can view when a package was installed or updated, and what packages were installed alongside it with the info history command:
[root@server ~] # yum history info ea-php73
Loaded plugins: fastestmirror, universal-hooks
Transaction ID : 100
Begin time : Thu Jan 1 00:00:00 1970
Begin rpmdb : aaaa:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
End time : 22:53:26 2021 (9 seconds)
End rpmdb : aaaa:aaaaaaaaaaaaaaaaaaaaaaaaaaaaab
User : root <root>
Return-Code : Success
Command Line : --assumeyes --color=never --config /etc/yum.conf --disableplugin fastestmirror install ea-php73
Transaction performed with:
Installed rpm-4.11.3-45.el7.x86_64 @base
Installed yum-3.4.3-168.el7.centos.noarch @base
Installed yum-metadata-parser-1.1.4-10.el7.x86_64 @anaconda
Packages Altered:
Install ea-php73-7.3.28-1.1.1.cpanel.x86_64 @EA4
Installing a package
You can install a package using the command below where PACKAGE is the package name.
yum install PACKAGE
For example, if you want to install the PHP 7.4 Intl extension we just found.
yum install ea-php74-php-intl
Removing a package
You can remove a package with the command below, where PACKAGE is the package name.
yum remove PACKAGE
For example, removing the PHP 7.4 Intl extension we just installed.
yum remove ea-php74-php-intl
Always review the packages that will be removed as the package you are attempting to remove may be a dependency of other packages. Removing needed packages could potentially result in irreparable damage to the server.
Updating a package
You can update a package with the command below, where PACKAGE is the package name.
yum update PACKAGE
For example, updating the sudo package.
yum update sudo
Updating all packages
You can update all packages by running the update command without any packages specified like so.
yum update