YUM Commands for Package Management

YUM Commands for Package Management

What is YUM?


YUM (Yellowdog Updater Modified) is an open source command-line as well as graphical based package management tool for RPM (RedHat Package Manager) based Linux systems. It allows users and system administrator to easily install, update, remove or search software packages on a systems. It was developed and released by Seth Vidal under GPL (General Public License) as an open source, means anyone can 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.

The example commands shown in this article are practically tested on our RHEL 8.4 server

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
Updating Subscription Management repositories.
Last metadata expiration check: 3:47:33 ago on Wed 16 Jun 2021 07:45:16 AM CEST.
Package firefox-78.9.0-1.el8_3.x86_64 is already installed.
Dependencies resolved.
===============================================================================================
 Package       Architecture Version               Repository                              Size
===============================================================================================
Upgrading:
 firefox       x86_64       78.11.0-3.el8_4       rhel-8-for-x86_64-appstream-rpms       102 M

Transaction Summary
===============================================================================================
Upgrade  1 Package

Total download size: 102 M
Is this ok [y/N]: 

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 below example.

~] yum -y install 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
Updating Subscription Management repositories.
Dependencies resolved.
===============================================================================================
 Package                   Architecture    Version                   Repository           Size
===============================================================================================
Removing:
 firefox                   x86_64          78.9.0-1.el8_3            @AppStream          248 M
Removing unused dependencies:
 redhat-indexhtml          noarch          8-7.el8                   @anaconda           535 k

Transaction Summary
===============================================================================================
Remove  2 Packages

Freed space: 249 M
Is this ok [y/N]: 

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

Updating a Package using YUM

Let’s say you have outdated version of openssh package and you want to update it to the latest stable version. Just run the following command it will automatically resolves all dependencies issues and install them.

~] yum update openssh
Updating Subscription Management repositories.
Last metadata expiration check: 0:37:37 ago on Wed 16 Jun 2021 11:47:16 AM CEST.
Dependencies resolved.
===============================================================================================
 Package             Arch       Version             Repository                            Size
===============================================================================================
Upgrading:
 openssh             x86_64     8.0p1-6.el8_4.2     rhel-8-for-x86_64-baseos-rpms        521 k
 openssh-askpass     x86_64     8.0p1-6.el8_4.2     rhel-8-for-x86_64-appstream-rpms      92 k
 openssh-clients     x86_64     8.0p1-6.el8_4.2     rhel-8-for-x86_64-baseos-rpms        667 k
 openssh-server      x86_64     8.0p1-6.el8_4.2     rhel-8-for-x86_64-baseos-rpms        484 k

Transaction Summary
===============================================================================================
Upgrade  4 Packages

Total download size: 1.7 M
Is this ok [y/N]: 

List a Package using YUM

Use the list function to search for the specific package with name. For example to search for a package called openssh, use the command.

~] yum list openssh
Updating Subscription Management repositories.
Last metadata expiration check: 0:39:37 ago on Wed 16 Jun 2021 11:47:16 AM CEST.
Installed Packages
openssh.x86_64                  8.0p1-5.el8                       @anaconda                    
Available Packages
openssh.x86_64                  8.0p1-6.el8_4.2                   rhel-8-for-x86_64-baseos-rpms

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 matches the word.

~] yum search vsftpd
Updating Subscription Management repositories.
Last metadata expiration check: 0:41:37 ago on Wed 16 Jun 2021 11:47:16 AM CEST.
================================ Name Exactly Matched: vsftpd =================================
vsftpd.x86_64 : Very Secure Ftp Daemon

Get Information of a Package using YUM

Say you would like to know information of a package before installing it. To get information of a package just issue the below command.

~] yum info vsftpd
Updating Subscription Management repositories.
Last metadata expiration check: 0:42:57 ago on Wed 16 Jun 2021 11:47:16 AM CEST.
Available Packages
Name         : vsftpd
Version      : 3.0.3
Release      : 33.el8
Architecture : x86_64
Size         : 180 k
Source       : vsftpd-3.0.3-33.el8.src.rpm
Repository   : rhel-8-for-x86_64-appstream-rpms
Summary      : Very Secure Ftp Daemon
URL          : https://security.appspot.com/vsftpd.html
License      : GPLv2 with exceptions
Description  : vsftpd is a Very Secure FTP daemon. It was written completely from
             : scratch.

List all Available Packages using YUM

To list all the available packages in the Yum database, use the below command.

~] yum list

List all Installed Packages using YUM

To list all the installed packages on a system, just issue below command, it will display all the installed packages.

~] yum list installed

Find rpm package which contain a full path filename

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 
Updating Subscription Management repositories.
Last metadata expiration check: 0:45:16 ago on Wed 16 Jun 2021 11:47:16 AM CEST.
openssh-server-7.8p1-4.el8.x86_64 : An open source SSH server daemon
Repo        : rhel-8-for-x86_64-baseos-rpms
Matched from:
Filename    : /etc/ssh/sshd_config

openssh-server-8.0p1-3.el8.x86_64 : An open source SSH server daemon
Repo        : rhel-8-for-x86_64-baseos-rpms
Matched from:
Filename    : /etc/ssh/sshd_config

openssh-server-8.0p1-4.el8_1.x86_64 : An open source SSH server daemon
Repo        : rhel-8-for-x86_64-baseos-rpms
Matched from:
Filename    : /etc/ssh/sshd_config

openssh-server-8.0p1-5.el8.x86_64 : An open source SSH server daemon
Repo        : @System
Matched from:
Filename    : /etc/ssh/sshd_config

openssh-server-8.0p1-5.el8.x86_64 : An open source SSH server daemon
Repo        : rhel-8-for-x86_64-baseos-rpms
Matched from:
Filename    : /etc/ssh/sshd_config

openssh-server-8.0p1-6.el8_4.2.x86_64 : An open source SSH server daemon
Repo        : rhel-8-for-x86_64-baseos-rpms
Matched from:
Filename    : /etc/ssh/sshd_config

Find rpm package which contain a filename

example: When you want find a package which contain a file libgcc_s.so.1 and you don't know a full path to this filename:

~] yum provides \*/libgcc_s.so.1
Updating Subscription Management repositories.
Last metadata expiration check: 0:50:54 ago on Wed 16 Jun 2021 11:47:16 AM CEST.
libgcc-8.2.1-3.5.el8.i686 : GCC version 8 shared support library
Repo        : rhel-8-for-x86_64-baseos-rpms
Matched from:
Filename    : /lib/libgcc_s.so.1

libgcc-8.2.1-3.5.el8.x86_64 : GCC version 8 shared support library
Repo        : rhel-8-for-x86_64-baseos-rpms
Matched from:
Filename    : /lib64/libgcc_s.so.1

libgcc-8.3.1-4.5.el8.i686 : GCC version 8 shared support library
Repo        : rhel-8-for-x86_64-baseos-rpms
Matched from:
Filename    : /lib/libgcc_s.so.1

libgcc-8.3.1-4.5.el8.x86_64 : GCC version 8 shared support library
Repo        : rhel-8-for-x86_64-baseos-rpms
Matched from:
Filename    : /lib64/libgcc_s.so.1

libgcc-8.3.1-5.el8.i686 : GCC version 8 shared support library
Repo        : rhel-8-for-x86_64-baseos-rpms
Matched from:
Filename    : /lib/libgcc_s.so.1

libgcc-8.3.1-5.el8.x86_64 : GCC version 8 shared support library
Repo        : rhel-8-for-x86_64-baseos-rpms
Matched from:
Filename    : /lib64/libgcc_s.so.1

libgcc-8.3.1-5.1.el8.i686 : GCC version 8 shared support library
Repo        : rhel-8-for-x86_64-baseos-rpms
Matched from:
Filename    : /lib/libgcc_s.so.1

libgcc-8.3.1-5.1.el8.x86_64 : GCC version 8 shared support library
Repo        : rhel-8-for-x86_64-baseos-rpms
Matched from:
Filename    : /lib64/libgcc_s.so.1

libgcc-8.4.1-1.el8.i686 : GCC version 8 shared support library
Repo        : rhel-8-for-x86_64-baseos-rpms
Matched from:
Filename    : /lib/libgcc_s.so.1

libgcc-8.4.1-1.el8.x86_64 : GCC version 8 shared support library
Repo        : @System
Matched from:
Filename    : /lib64/libgcc_s.so.1

libgcc-8.4.1-1.el8.x86_64 : GCC version 8 shared support library
Repo        : rhel-8-for-x86_64-baseos-rpms
Matched from:
Filename    : /lib64/libgcc_s.so.1

Check for Available Updates using Yum

To find how many of installed packages on your system have updates available, to check use the following command.

~] yum check-update

Update System using Yum

~] yum update