Best Yum Command With Examples A Package Manager In Rhel/Centos/Fedora

In this article, we are going to learn some most useful yum command with example. YUM is a Package Manager tool and most convenient way to handle packages and its dependencies. YUM stands for Yellowpage Updater Modifier is a Package Manager tool for rpm package supportable Linux distros/Operating Systems ex: RHEL 5/6/7 and so on. It is used to install, uninstall, update, list available packages, list installed packages and search the rpm packages from the database. The main purpose of yum is to install rpm packages easily with all required dependencies and convenient way of package manager for administrators. YUM was first introduced on RHEL 5 then available on all later versions. When we try to install some package from client-side using yum commands it’s downloading the requested package and its dependencies from YUM Repository Package Manager Server and makes us available to install it.

Best Yum Command With Examples A Package Manager In Rhel/Centos/Fedora

Yum Commands With Examples A Package Manager In Rhel/Centos/Fedora

So let’s have a look at yum commands examples.

1. Install a Package using YUM Command

To install a package using yum command follow the below command, Here I am installing DHCP package.

[root@itsmarttricks ~]# yum install dhcp   # Install DHCP Package using yum command
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirrors.nhanhoa.com
 * updates: centos-hcm.viettelidc.com.vn
base                                                     | 3.7 kB     00:00     
extras                                                   | 3.4 kB     00:00     
updates                                                  | 3.4 kB     00:00     
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.1.1-51.P1.el6.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package     Arch          Version                            Repository   Size
================================================================================
Installing:
 dhcp        x86_64        12:4.1.1-51.P1.el6.centos          base        823 k

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 823 k
Installed size: 1.9 M
Is this ok [y/N]: y
Downloading Packages:
dhcp-4.1.1-51.P1.el6.centos.x86_64.rpm                   | 823 kB     00:01     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 12:dhcp-4.1.1-51.P1.el6.centos.x86_64                        1/1 
  Verifying  : 12:dhcp-4.1.1-51.P1.el6.centos.x86_64                        1/1 

Installed:
  dhcp.x86_64 12:4.1.1-51.P1.el6.centos                                         

Complete!

You can also use yum command with option -y. This will assume Yes for any question asked during package installation. for example :

Total download size: 913 k
Is this ok [y/N]: y
[root@itsmarttricks ~]# yum -y install dhcp   # Install dhcp package using yum with -y

2. Update all Installed Packages or a Single Package using YUM Command

We can use yum command to update an already installed package from its lower version to upper released version.

To update all installed Packages and Repositories just run the command yum update. Refer to the output below.

[root@itsmarttricks ~]# yum update   # Update all Installed Packages and Repositories

To Update a particular package you have to mention the package name, Here I am updating HTTPd package. Refer to the output below.

[root@itsmarttricks ~]# yum update httpd   # Update httpd Package
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Update Process
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirrors.nhanhoa.com
 * updates: centos-hcm.viettelidc.com.vn
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-55.el6.centos.2 will be updated
---> Package httpd.x86_64 0:2.2.15-56.el6.centos.3 will be an update
--> Processing Dependency: httpd-tools = 2.2.15-56.el6.centos.3 for package: httpd-2.2.15-56.el6.centos.3.x86_64
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.2.15-55.el6.centos.2 will be updated
---> Package httpd-tools.x86_64 0:2.2.15-56.el6.centos.3 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package          Arch        Version                        Repository    Size
================================================================================
Updating:
 httpd            x86_64      2.2.15-56.el6.centos.3         updates      834 k
Updating for dependencies:
 httpd-tools      x86_64      2.2.15-56.el6.centos.3         updates       79 k

Transaction Summary
================================================================================
Upgrade       2 Package(s)

Total download size: 913 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): httpd-2.2.15-56.el6.centos.3.x86_64.rpm           | 834 kB     00:06     
(2/2): httpd-tools-2.2.15-56.el6.centos.3.x86_64.rpm     |  79 kB     00:00     
--------------------------------------------------------------------------------
Total                                           114 kB/s | 913 kB     00:07     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : httpd-tools-2.2.15-56.el6.centos.3.x86_64                    1/4 
  Updating   : httpd-2.2.15-56.el6.centos.3.x86_64                          2/4 
  Cleanup    : httpd-2.2.15-55.el6.centos.2.x86_64                          3/4 
  Cleanup    : httpd-tools-2.2.15-55.el6.centos.2.x86_64                    4/4 
  Verifying  : httpd-2.2.15-56.el6.centos.3.x86_64                          1/4 
  Verifying  : httpd-tools-2.2.15-56.el6.centos.3.x86_64                    2/4 
  Verifying  : httpd-tools-2.2.15-55.el6.centos.2.x86_64                    3/4 
  Verifying  : httpd-2.2.15-55.el6.centos.2.x86_64                          4/4 

Updated:
  httpd.x86_64 0:2.2.15-56.el6.centos.3                                         

Dependency Updated:
  httpd-tools.x86_64 0:2.2.15-56.el6.centos.3                                   

Complete!

3. List Packages using yum command

To list all installed packages in system and available packages in YUM repository Package Manager server use the command yum list, Refer the Sample output below.

[root@itsmarttricks ~]# yum list   # List all Installed and Available Packages

To list only installed packages use command yum list installed, Refer the output below.

[root@itsmarttricks ~]# yum list installed   # List only Installed Packages

To list particular package use command yum list <Package Name>. If the package is already installed then you will see the output as Installed Package and if the package is not installed then you will get the output as Available Package. Here Available package means the package is available in YUM Repository Package Manager Server to install.

For example DHCP package is currently not installed in my system, In that case, when I am trying to list for package DHCP It is showing as Available Package (Highlighted in Red color on the output below).

[root@itsmarttricks ~]# yum list dhcp
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirrors.nhanhoa.com
 * updates: centos-hcm.viettelidc.com.vn
Available Packages
dhcp.x86_64                    12:4.1.1-51.P1.el6.centos                    base

And HTTPd package is installed in my system, When I am trying to list HTTPd package it is showing me as Installed Package (Highlighted in Red color on the output below).

[root@itsmarttricks ~]# yum list httpd
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirrors.nhanhoa.com
 * updates: centos-hcm.viettelidc.com.vn
Installed Packages
httpd.x86_64                   2.2.15-56.el6.centos.3                   @updates

To list recently added packages to YUM Repository Package Manager Server use command yum list recent. Follow the sample output below.

[root@itsmarttricks ~]# yum list recent   # To list recently add packages to YUM Repository Package Manager Server
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: centos-hn.viettelidc.com.vn
 * updates: centos-hn.viettelidc.com.vn
Recently Added Packages
openjpeg.x86_64                            1.3-16.el6_8                  updates
openjpeg-devel.i686                        1.3-16.el6_8                  updates
openjpeg-devel.x86_64                      1.3-16.el6_8                  updates
openjpeg-libs.i686                         1.3-16.el6_8                  updates
openjpeg-libs.x86_64                       1.3-16.el6_8                  updates
tomcat6.noarch                             6.0.24-105.el6_8              updates
tomcat6-admin-webapps.noarch               6.0.24-105.el6_8              updates
tomcat6-docs-webapp.noarch                 6.0.24-105.el6_8              updates
tomcat6-el-2.1-api.noarch                  6.0.24-105.el6_8              updates
tomcat6-javadoc.noarch                     6.0.24-105.el6_8              updates
tomcat6-jsp-2.1-api.noarch                 6.0.24-105.el6_8              updates
tomcat6-lib.noarch                         6.0.24-105.el6_8              updates
tomcat6-servlet-2.5-api.noarch             6.0.24-105.el6_8              updates
tomcat6-webapps.noarch                     6.0.24-105.el6_8              updates

4. Uninstall/Erase/Remove a Package

To Uninstall or Remove a package use the below command, Here I am Uninstalling dhcp package.

[root@itsmarttricks ~]# yum remove dhcp   # Uninstall dhcp Package
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.1.1-51.P1.el6.centos will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package     Arch          Version                           Repository    Size
================================================================================
Removing:
 dhcp        x86_64        12:4.1.1-51.P1.el6.centos         @base        1.9 M

Transaction Summary
================================================================================
Remove        1 Package(s)

Installed size: 1.9 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : 12:dhcp-4.1.1-51.P1.el6.centos.x86_64                        1/1 
  Verifying  : 12:dhcp-4.1.1-51.P1.el6.centos.x86_64                        1/1 

Removed:
  dhcp.x86_64 12:4.1.1-51.P1.el6.centos                                         

Complete!

5. Check Information of a Package

We can use yum command to check the Package Information like Package Architecture, Version, Size, Description etc.. To check the Package information use command yum info <Package Name>, Refer the output below. Here I am checking the information of dhcp Package.

[root@itsmarttricks ~]# yum info dhcp   # Check Information of dhcp Package
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirrors.nhanhoa.com
 * updates: centos-hcm.viettelidc.com.vn
Available Packages
Name        : dhcp
Arch        : x86_64
Epoch       : 12
Version     : 4.1.1
Release     : 51.P1.el6.centos
Size        : 823 k
Repo        : base
Summary     : Dynamic host configuration protocol software
URL         : http://isc.org/products/DHCP/
License     : ISC
Description : DHCP (Dynamic Host Configuration Protocol) is a protocol which
            : allows individual devices on an IP network to get their own
            : network configuration information (IP address, subnetmask,
            : broadcast address, etc.) from a DHCP server. The overall purpose
            : of DHCP is to make it easier to administer a large network.  The
            : dhcp package includes the ISC DHCP service and relay agent.
            : 
            : To use DHCP on your network, install a DHCP service (or relay
            : agent), and on clients run a DHCP client daemon.  The dhcp package
            : provides the ISC DHCP service and relay agent.

6. YUM Help for More Options and Features

To refer more yum command options and features you can use yum help.

[root@itsmarttricks ~]# yum help   # To access yum help page for more yum features and options

7. Reinstall a Package using yum command

To Reinstalled an already installed package we can use command yum reinstall <Package Name>, Refer the output below.

[root@itsmarttricks ~]# yum reinstall httpd   # Reinstall httpd Package
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Reinstall Process
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirrors.nhanhoa.com
 * updates: centos-hcm.viettelidc.com.vn
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-56.el6.centos.3 will be reinstalled
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package      Arch          Version                        Repository      Size
================================================================================
Reinstalling:
 httpd        x86_64        2.2.15-56.el6.centos.3         updates        834 k

Transaction Summary
================================================================================
Reinstall     1 Package(s)

Total download size: 834 k
Installed size: 3.0 M
Is this ok [y/N]: y
Downloading Packages:
httpd-2.2.15-56.el6.centos.3.x86_64.rpm                  | 834 kB     00:05     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : httpd-2.2.15-56.el6.centos.3.x86_64                          1/1 
  Verifying  : httpd-2.2.15-56.el6.centos.3.x86_64                          1/1 

Installed:
  httpd.x86_64 0:2.2.15-56.el6.centos.3                                         

Complete!

8. Install and Manage Group Packages using YUM Command

We can install Group Packages using yum command. Group Package is nothing but a bunch of packages which may concern with some single device, for example, a group may contain all package related to all Languages or Drivers of the system or some firmware, etc.

We can check a group package contains what list of packages by using yum groupinfo “<Group Package Name>”, Refer the Output below.

[root@itsmarttricks ~]# yum -y groupinfo "Desktop"   # Check the Informating of Group Package
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Group Process
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirrors.nhanhoa.com
 * updates: centos-hcm.viettelidc.com.vn

Group: Desktop
 Description: A minimal desktop that can also be used as a thin client.
 Mandatory Packages:
   NetworkManager
   NetworkManager-gnome
   alsa-plugins-pulseaudio
   at-spi
   control-center
   dbus
   gdm
   gdm-user-switch-applet
   gnome-panel
   gnome-power-manager
   gnome-screensaver
   gnome-session
   gnome-terminal
   gvfs-archive
   gvfs-fuse
   gvfs-smb
   metacity
   nautilus
   notification-daemon
   polkit-gnome
   xdg-user-dirs-gtk
   yelp
 Default Packages:
   control-center-extra
   eog
   gdm-plugin-fingerprint
   gnome-applets
   gnome-media
   gnome-packagekit
   gnome-vfs2-smb
   gok
   openssh-askpass
   orca
   pulseaudio-module-gconf
   pulseaudio-module-x11
   vino
 Optional Packages:
   sabayon-apply
   tigervnc-server
   xguest

To install a Group Package use the command yum groupinstall “<Group Package Name>”.

[root@itsmarttricks ~]# yum groupinstall "Desktop"   # Install Group Package

To list available group packages which are installed or in YUM Repository Server you can use command yum grouplist, Refer the output below.

[root@itsmarttricks ~]# yum grouplist   # List the Available Group Packages which are installed or in YUM Repository Package Manager Server

To update the already installed group package from Lower version to latest released version use below command.

[root@itsmarttricks ~]# yum groupupdate "Desktop"   # To update the Group Package

To Uninstall a Group Package use the below command.

[root@itsmarttricks ~]# yum groupremove "Desktop"   # To Uninstall a Group Package

9. Search for Package using YUM Command

To search for a Package using yum command use command yum search <Package Name>. Here I am searching for the dhcp package. Refer to the output below.

[root@itsmarttricks ~]# yum search dhcp   # Search for a Package using yum command
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirrors.nhanhoa.com
 * updates: centos-hcm.viettelidc.com.vn
============================== N/S Matched: dhcp ===============================
dhcp-common.x86_64 : Common files used by ISC dhcp client and server
dhcp-devel.i686 : Development headers and libraries for interfacing to the DHCP
                : server
dhcp-devel.x86_64 : Development headers and libraries for interfacing to the
                  : DHCP server
sblim-cmpi-dhcp.i686 : SBLIM WBEM-SMT DHCP
sblim-cmpi-dhcp.x86_64 : SBLIM WBEM-SMT DHCP
sblim-cmpi-dhcp-devel.i686 : SBLIM WBEM-SMT DHCP - Header Development Files
sblim-cmpi-dhcp-devel.x86_64 : SBLIM WBEM-SMT DHCP - Header Development Files
sblim-cmpi-dhcp-test.x86_64 : SBLIM WBEM-SMT DHCP - Testcase Files
dhclient.x86_64 : Provides the dhclient ISC DHCP client daemon and
                : dhclient-script
dhcp.x86_64 : Dynamic host configuration protocol software
dnsmasq.x86_64 : A lightweight DHCP/caching DNS server
dnsmasq-utils.x86_64 : Utilities for manipulating DHCP server leases

  Name and summary matches only, use "search all" for everything.

10. Clean cached installed files during Installation or Updation

When we are trying to install any package through yum command yum extracts the rpm package on our system and then installs the package. but after installing the package the extracted files are stores there only which may unnecessarily use our disk space. We can clean that unused file by yum clean command.

[root@itsmarttricks ~]# yum clean packages   # To clean all unwanted files created during package installation
[root@itsmarttricks ~]# yum clean all   # To clean all unwanted extracted files

11. List available Repositories

Check all enabled Repositories use command yum repolist, Refer the output below.

[root@itsmarttricks ~]# yum repolist   # Check enabled repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
 * base: mirror.nbrc.ac.in
 * extras: centos-hn.viettelidc.com.vn
 * updates: centos-hn.viettelidc.com.vn
base                                                     | 3.7 kB     00:00     
base/primary_db                                          | 4.7 MB     00:08     
extras                                                   | 3.4 kB     00:00     
extras/primary_db                                        |  37 kB     00:00     
updates                                                  | 3.4 kB     00:00     
updates/primary_db                                       | 5.4 MB     00:09     
repo id                        repo name                                  status
base                           CentOS-6 - Base                            6,696
extras                         CentOS-6 - Extras                             64
updates                        CentOS-6 - Updates                           974
repolist: 7,734

That’s all, In this article, we have explained Yum Commands With Examples A Package Manager In Rhel/Centos/Fedora7. I hope you enjoy this article. If you like this article, then just share it. If you have any questions about this article, please comment

Share this:

Mangesh Dhulap

This is Mangesh Dhulap the Founder and Editor of IT SMART TRICKS have 6+ years of Industrial Experience. We expect from our visitors to like, share, and comment on our posts.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.