In this blog, we will learn how to install, update, remove, find packages, manage packages and repositories on Linux systems using YUM (Yellowdog Updater Modified) tool developed by RedHat. This blog also contains a Cheat Sheet of some basic commands of YUM.
What is YUM?
YUM (Yellowdog Updater Modified) is an open-source command-line as well as a graphical based package management tool for RPM (RedHat Package Manager) based Linux systems. It allows users and system administrators to easily install, update, remove or search software packages on a system. It was developed and released by Seth Vidal under GPL (General Public License) as an open-source, which means anyone can be allowed to download and access the code to fix bugs and develop customized packages. YUM uses numerous third-party repositories to install packages automatically by resolving their dependencies issues.
Following example, usages show the most commonly used options for performing package installation with yum :
Install a Package with YUM
To install a package called Firefox, just run the below command it will automatically find and install all required dependencies for Firefox.
# yum install firefox Loaded plugins: fastestmirror Dependencies Resolved =================================================================================================================================================================================================================== Package Arch Version Repository Size =================================================================================================================================================================================================================== Installing: firefox x86_64 68.6.0-1.el7.centos updates 94 M Transaction Summary =================================================================================================================================================================================================================== Install 1 Package Total download size: 94 M Is this ok [y/d/N]: y Downloading packages: firefox-68.6.0-1.el7.centos.x86_64.rpm | 94 MB 00:03:04 Installing : firefox-68.6.0-1.el7.centos.x86_64 1/1 Verifying : firefox-68.6.0-1.el7.centos.x86_64 1/1 Installed: firefox.x86_64 0:68.6.0-1.el7.centos Complete!
The above command will ask confirmation before installing any package on your system. If you want to install packages automatically without asking any confirmation, use option -y as shown in the below example.
# yum -y remove firefox
Removing a Package with YUM
To remove a package completely with their all dependencies, just run the following command as shown below.
# yum remove firefox.x86_64 Loaded plugins: fastestmirror Dependencies Resolved ========================================================================================================================================================= Package Arch Version Repository Size ========================================================================================================================================================= Removing: firefox x86_64 68.6.0-1.el7.centos @updates 230 M Transaction Summary ========================================================================================================================================================= Remove 1 Package Installed size: 230 M Is this ok [y/N]: y Running transaction Erasing : firefox-68.6.0-1.el7.centos.x86_64 Verifying : firefox-68.6.0-1.el7.centos.x86_64 1/1 Removed: firefox.x86_64 0:68.6.0-1.el7.centos Complete!
Same way the above command will ask confirmation before removing a package. To disable confirmation prompt just add option -y as shown in below.
# yum -y remove firefox
Upgrading a Package using YUM
We can also upgrade any installed package to the latest stable version. For e.g. we’ve to upgrade the version of vsftd. Just run the following command it will automatically resolve all dependencies issues and install them.
# yum upgrade vsftpd Loaded plugins: fastestmirror Dependencies Resolved ========================================================================================================================================================== Package Arch Version Repository Size ========================================================================================================================================================== Updating: vsftpd i386 2.0.5-24.el5_8.1 updates 144 k Transaction Summary ========================================================================================================================================================== Install 0 Package(s) Upgrade 1 Package(s) Total size: 144 k Is this ok [y/N]: y Downloading Packages: Transaction Test Succeeded Running Transaction Updating : vsftpd 1/2 Cleanup : vsftpd 2/2 Updated: vsftpd.i386 0:2.0.5-24.el5_8.1 Complete!
Downgrading a Package using YUM
There will be occasions when a program update may have lead to an unstable system due to hardware compatibility issues. For this or whatever the reason, if you want your previous version program back, you need to know how to downgrade the applications.
# yum downgrade httpd-2.2.3-22.el5 Dependencies Resolved ==================================================================================================================================================== Package Arch Version Repository Size ==================================================================================================================================================== Installing: httpd i386 2.2.3-22.el5 rhel-i386-server-5 1.2 M Removing: httpd i386 2.2.3-31.el5 installed 3.1 M Removing for dependencies: httpd-manual i386 2.2.3-31.el5 installed 3.4 M mod_ssl i386 1:2.2.3-31.el5 installed 173 k Transaction Summary ==================================================================================================================================================== Install 1 Package(s) Update 0 Package(s) Remove 3 Package(s) Total download size: 1.2 M Is this ok [y/N]:
List Packages using YUM
Use the list function to search for the specific package with name, recently installed, updates available, etc. For example, to search for a package called OpenSSH, use the command.
# yum list openssh Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.mirrors.estointernet.in * extras: centos.mirrors.estointernet.in * updates: centos.mirrors.estointernet.in Installed Packages openssh.x86_64 7.4p1-21.el7 @anaconda
To list all the installed packages in a system, use the following command.
# yum list installed
To list all recently installed packages, use the following command.
# yum list recent
Use the following command to list the packages with updates available.
# yum list updates
Search for a Package using YUM
If you don’t remember the exact name of the package, then use search function to search all the available packages to match the name of the package you specified. For example, to search all the packages that match the word .
# yum search firefox Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net =================================================== N/S matched: firefox ============================================================= firefox.i686 : Mozilla Firefox Web browser firefox.x86_64 : Mozilla Firefox Web browser
Get Information of a Package using YUM
Say you would like to know the information about a package before installing it. To get information about a package just issue the below command.
# yum info firefox Loaded plugins: fastestmirror * base: centos.excellmedia.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net Available Packages Name : firefox Arch : i686 Version : 68.6.0 Release : 1.el7.centos Size : 97 M Repo : updates/7/x86_64 Summary : Mozilla Firefox Web browser URL : https://www.mozilla.org/firefox/ License : MPLv1.1 or GPLv2+ or LGPLv2+ Description : Mozilla Firefox is an open-source web browser, designed for standards compliance, performance and portability.
List all Dependencies of a Package using YUM
You can check the list of all Dependencies required by a specific package using the following command.
# yum deplist vsftpd Loaded plugins: fastestmirror * base: mirrors.praction.in * extras: mirrors.praction.in * updates: mirrors.praction.in package: vsftpd.x86_64 3.0.2-25.el7 dependency: /bin/bash provider: bash.x86_64 4.2.46-33.el7 dependency: /bin/sh provider: bash.x86_64 4.2.46-33.el7 dependency: libc.so.6(GLIBC_2.15)(64bit)
Yum Provides Function
Yum provides function is used to find which package a specific file belongs to. For example, if you would like to know the name of the package that has the /etc/ssh/sshd_config.
# yum provides /etc/ssh/sshd_config Loaded plugins: fastestmirror * base: centos.excellmedia.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net openssh-server-7.4p1-21.el7.x86_64 : An open source SSH server daemon Repo : base Matched from: Filename : /etc/ssh/sshd_config openssh-server-7.4p1-21.el7.x86_64 : An open source SSH server daemon Repo : @anaconda Matched from: Filename : /etc/ssh/sshd_config
Check for Available Updates using Yum
Find how many installed packages on your system have updates available, use the following command to check.
# yum check-update
Update System using Yum
To keep your system up-to-date with all security and binary package updates, run the following command. It will install all the latest patches and security updates to your system.
# yum update
List all available Group Packages
In Linux, number of packages are bundled to a particular group. Instead of installing individual packages with yum, you can install a particular group that will install all the related packages that belong to the group. For example to list all the available groups, just issue following command.
# yum groups list Loaded plugins: fastestmirror * base: centos.excellmedia.net * extras: centos.mirror.snu.edu.in * updates: centos.mirror.snu.edu.in Available Environment Groups: Minimal Install Compute Node Infrastructure Server File and Print Server Basic Web Server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Development and Creative Workstation Available Groups: Compatibility Libraries Graphical Administration Tools Security Tools System Administration Tools
Install a Group Packages
Install a particular package group, use option groups install. For example, to install “Development Tools“, execute the below command.
# yum groups install "Development Tools"
Update a Group Packages
To update any existing installed group packages, just run the following command as shown below.
# yum groups update 'DNS Name Server'
Get details of a Group Packages
Display details about a group of packages from the system, just use the below command.
yum groups info "System Administration Tools"
Remove a Group Packages
Delete or remove any existing installed group from the system, just use the below command.
#yum groups remove 'DNS Name Server'
List Enabled Yum Repositories
Get the list of all enabled Yum repositories in your system, use following command.
# yum repolist Loaded plugins: fastestmirror * base: centos.excellmedia.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net repo id repo name status base/7/x86_64 CentOS-7 - Base 10,097 extras/7/x86_64 CentOS-7 - Extras 341 updates/7/x86_64 CentOS-7 - Updates 1,787 repolist: 12,225
List all Enabled and Disabled Yum Repositories
The following command will display all enabled and disabled yum repositories on the system.
# yum repolist all
Interactive Yum Shell
Yum utility provides a custom shell where you can execute multiple commands.
# yum shell Loaded plugins: fastestmirror > search named Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net ======================================================== N/S matched: named ================================================================= pcp-pmda-named.x86_64 : Performance Co-Pilot (PCP) metrics for Named bind-chroot.x86_64 : A chroot runtime environment for the ISC BIND DNS server, named(8) bind-sdb-chroot.x86_64 : A chroot runtime environment for the ISC BIND DNS server, named-sdb(8) Name and summary matches only, use "search all" for everything. >
Clean Yum Cache
By default yum keeps all the repository enabled package data in /var/cache/yum/ with each sub-directory, to clean all cached files from enabled repository, you need to run the following command regularly to clean up all the cache and make sure that there is nothing unnecessary space is using.
# yum clean all
View History of Yum
To view all the past transactions of yum command, just use the following command.
# yum history Loaded plugins: fastestmirror ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 8 | root <root> | 2020-04-06 13:09 | Install | 1 7 | root <root> | 2020-04-06 12:15 | Install | 31 6 | root <root> | 2020-04-06 12:02 | Erase | 1 EE 5 | root <root> | 2020-04-06 11:43 | Install | 1 4 | root <root> | 2020-04-06 11:39 | Erase | 1 EE 3 | root <root> | 2020-03-30 17:17 | Install | 84 2 | root <root> | 2020-03-30 17:15 | Install | 1 1 | System <unset> | 2020-03-30 16:50 | Install | 301 history list