YUM Stands for Yellowdog Updater, Modified. In this document we’ll see how to install, remove, upgrade new packages using YUM. In addition to the above, YUM has got many features and lets see them one by one.

1. Install a package

To install a package, do ‘yum install packagename’. This will also identify the dependencies automatically and install them.

[root@ServerCraftmen yum.repos.d]# yum install lynx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.lga7.us.voxel.net
* extras: centos.mirror.constant.com
* updates: centos.gravityfish.com
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package lynx.x86_64 0:2.8.6-27.el6 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
Package                              Arch                                   Version                                         Repository                            Size
========================================================================================================================================================================
Installing:
lynx                                 x86_64                                 2.8.6-27.el6                                    base                                 1.3 M

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

Total download size: 1.3 M
Installed size: 4.7 M
Is this ok [y/N]: y
Downloading Packages:
lynx-2.8.6-27.el6.x86_64.rpm                                                                                                                     | 1.3 MB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 3 pre-existing rpmdb problem(s), ‘yum check’ output follows:
dracut-004-53.el6.noarch has missing requires of plymouth >= (‘0′, ‘0.8.0’, ‘0.2009.29.09.19.1’)
dracut-004-53.el6.noarch has missing requires of plymouth-scripts
1:grub-0.97-70.el6.x86_64 has missing requires of system-logos
Installing : lynx-2.8.6-27.el6.x86_64                                                                                                                             1/1

Installed:
lynx.x86_64 0:2.8.6-27.el6

Complete!
[root@ServerCraftmen yum.repos.d]#

User -y option if you want to install without any prompts.

2. Uninstall a package

Use yum remove to uninstall a package along with all its dependencies.

[root@ServerCraftmen yum.repos.d]# yum remove lynx
Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
–> Running transaction check
—> Package lynx.x86_64 0:2.8.6-27.el6 will be erased
–> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
Package                              Arch                                   Version                                        Repository                             Size
========================================================================================================================================================================
Removing:
lynx                                 x86_64                                 2.8.6-27.el6                                   @base                                 4.7 M

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

Installed size: 4.7 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing    : lynx-2.8.6-27.el6.x86_64                                                                                                                             1/1

Removed:
lynx.x86_64 0:2.8.6-27.el6

Complete!
[root@ServerCraftmen yum.repos.d]#

3. Upgrade an existing package

Yum update will upgraded the older version of existing package to the latest. This will install/update the required dpendancies as well.

[root@ServerCraftmen yum.repos.d]# yum update curl
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.someimage.com
* extras: centos.mirror.constant.com
* updates: centos.gravityfish.com
Setting up Update Process
Resolving Dependencies
–> Running transaction check
—> Package curl.x86_64 0:7.19.7-26.el6 will be updated
—> Package curl.x86_64 0:7.19.7-37.el6_4 will be an update
–> Processing Dependency: libcurl = 7.19.7-37.el6_4 for package: curl-7.19.7-37.el6_4.x86_64
–> Running transaction check
—> Package libcurl.x86_64 0:7.19.7-26.el6 will be updated
—> Package libcurl.x86_64 0:7.19.7-37.el6_4 will be an update
–> Processing Dependency: libssh2(x86-64) >= 1.4.2 for package: libcurl-7.19.7-37.el6_4.x86_64
–> Running transaction check
—> Package libssh2.x86_64 0:1.2.2-7.el6 will be updated
—> Package libssh2.x86_64 0:1.4.2-1.el6 will be an update
–> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
Package                                Arch                                  Version                                         Repository                           Size
========================================================================================================================================================================
Updating:
curl                                   x86_64                                7.19.7-37.el6_4                                 base                                193 k
Updating for dependencies:
libcurl                                x86_64                                7.19.7-37.el6_4                                 base                                165 k
libssh2                                x86_64                                1.4.2-1.el6                                     base                                122 k

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

Total size: 480 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating   : libssh2-1.4.2-1.el6.x86_64                                                                                                                           1/6
Updating   : libcurl-7.19.7-37.el6_4.x86_64                                                                                                                       2/6
Updating   : curl-7.19.7-37.el6_4.x86_64                                                                                                                          3/6
Cleanup    : curl-7.19.7-26.el6.x86_64                                                                                                                            4/6
Cleanup    : libcurl-7.19.7-26.el6.x86_64                                                                                                                         5/6
Cleanup    : libssh2-1.2.2-7.el6.x86_64                                                                                                                           6/6

Updated:
curl.x86_64 0:7.19.7-37.el6_4

Dependency Updated:
libcurl.x86_64 0:7.19.7-37.el6_4                                                     libssh2.x86_64 0:1.4.2-1.el6

Complete!

4. Search for a package

yum search will search the yum repository for all the packages that matches the keyword which is used for search and lists the available packages.

[root@ServerCraftmen yum.repos.d]# yum search curl
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.someimage.com
* extras: centos.mirror.constant.com
* updates: centos.gravityfish.com
========================================================================== N/S Matched: curl ===========================================================================
libcurl-devel.i686 : Files needed for building applications with libcurl
libcurl-devel.x86_64 : Files needed for building applications with libcurl
perl-WWW-Curl.x86_64 : Perl extension interface for libcurl
python-pycurl.x86_64 : A Python interface to libcurl
curl.x86_64 : A utility for getting files from remote servers (FTP, HTTP, and others)
libcurl.i686 : A library for getting files from web servers
libcurl.x86_64 : A library for getting files from web servers

Name and summary matches only, use “search all” for everything. This will only check the name and summary fields. Use yum search all <keyword> to search everything.

5. Display additional information about a package

[root@server ~]# yum info httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.lga7.us.voxel.net
* extras: centos.mirror.constant.com
* updates: centos.gravityfish.com
Available Packages
Name        : httpd
Arch        : x86_64
Version     : 2.2.15
Release     : 29.el6.centos
Size        : 821 k
Repo        : base
Summary     : Apache HTTP Server
URL         : http://httpd.apache.org/
License     : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and extensible
: web server.

6. View all available packages in the repository

yum list will show all the available packages in the repositories configured.

[root@server ~]# yum list
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.us.leaseweb.net
* extras: mirror.ash.fastserv.com
* updates: mirrors.lga7.us.voxel.net
base                                                                                                                                             | 3.7 kB     00:00
extras                                                                                                                                           | 3.4 kB     00:00
updates                                                                                                                                          | 3.4 kB     00:00
updates/primary_db                                                                                                                               | 2.0 MB     00:00
Installed Packages
ConsoleKit.x86_64                                         0.4.1-3.el6                             @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
ConsoleKit-libs.x86_64                                    0.4.1-3.el6                             @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
MAKEDEV.x86_64                                            3.24-6.el6                              @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
PyXML.x86_64                                              0.8.4-19.el6                            @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
Red_Hat_Enterprise_Linux-Release_Notes-6-en-US.noarch     1-26.el6                                @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
abrt.x86_64                                               1.1.16-3.el6                            @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
abrt-addon-ccpp.x86_64                                    1.1.16-3.el6                            @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
………………………………………
……………………….

7. List all the installed packages

yum list installed will list only currently installed packages.

[root@server ~]# yum list installed
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.someimage.com
* extras: centos.mirror.constant.com
* updates: centos.gravityfish.com
Installed Packages
ConsoleKit.x86_64                                        0.4.1-3.el6                              @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
ConsoleKit-libs.x86_64                                   0.4.1-3.el6                              @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
MAKEDEV.x86_64                                           3.24-6.el6                               @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
PyXML.x86_64                                             0.8.4-19.el6                             @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
Red_Hat_Enterprise_Linux-Release_Notes-6-en-US.noarch    1-26.el6                                 @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
abrt.x86_64                                              1.1.16-3.el6                             @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
……………………………………………………
…………………………………….

8. To check in which package a file belongs to

yum provides is a handy tool to check in which package a specific file belongs to. For example :

[root@server ~]# yum provides /etc/issue
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.someimage.com
* extras: centos.mirror.constant.com
* updates: mirror.rackspace.com
centos-release-6-5.el6.centos.11.1.x86_64 : CentOS release file
Repo        : base
Matched from:
Filename    : /etc/issue

centos-release-6-5.el6.centos.11.2.x86_64 : CentOS release file
Repo        : updates
Matched from:
Filename    : /etc/issue

centos-release-6-1.el6.centos.6.x86_64 : CentOS release file
Repo        : installed
Matched from:
Other       : Provides-match: /etc/issue

YUM GROUPS

Several related packages are grouped together in a specific group. Instead of searching and installing all the individual packages that belongs to a specific function, you can simply install the group, which will install all the packages that belongs to the group.
To view all the available software groups execute ‘yum grouplist’ as shown below. The output is listed in three groups – Installed Groups, Installed Language Groups and Available Groups.

9 . List the three category of groups

[root@server ~]# yum grouplist
Loaded plugins: fastestmirror
Setting up Group Process
Loading mirror speeds from cached hostfile
* base: mirrors.lga7.us.voxel.net
* extras: mirror.es.its.nyu.edu
* updates: mirrors.cmich.edu
Installed Groups:
Additional Development
Compatibility libraries
Console internet tools
Desktop Platform
Directory Client
E-mail server
Fonts
Graphical Administration Tools
Hardware monitoring utilities
Legacy UNIX compatibility
Network file system client
Networking Tools
……………………
………….

10. Install a group

yum groupinstall will install a group of packages which is listed above.

root@server ~]# yum groupinstall “Malayalam Support”
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.someimage.com
* extras: centos.mirror.constant.com
* updates: centos.gravityfish.com
Setting up Group Process
Checking for new repos for mirrors
Resolving Dependencies
–> Running transaction check
—> Package hunspell-ml.noarch 0:0.1-4.1.el6 will be installed
—> Package iok.x86_64 0:1.3.13-3.el6 will be installed
—> Package smc-suruma-fonts.noarch 0:04.2-11.el6 will be installed
—> Package xkeyboard-config.noarch 0:2.6-6.el6 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
Package                                            Arch                             Version                                       Repository                      Size
========================================================================================================================================================================
Installing:
hunspell-ml                                        noarch                           0.1-4.1.el6                                   base                           735 k
iok                                                x86_64                           1.3.13-3.el6                                  base                            97 k
lohit-malayalam-fonts                              noarch                           2.4.4-5.el6                                   base                            46 k
m17n-contrib-malayalam                             noarch                           1.1.10-4.el6_1.1                              base                            23 k
m17n-db-malayalam                                  noarch                           1.5.5-1.1.el6                                 base                            18 k
samyak-malayalam-fonts                             noarch                           1.2.1-9.el6                                   base                            30 k
smc-anjalioldlipi-fonts                            noarch                           04.2-11.el6                                   base                            94 k
m17n-db                                            noarch                           1.5.5-1.1.el6                                 base                            41 k
samyak-fonts-common                                noarch                           1.2.1-9.el6                                   base                            18 k
smc-fonts-common                                   noarch                           04.2-11.el6                                   base                            13 k
unique                                             x86_64                           1.1.4-2.el6                                   base                            53 k
xkeyboard-config                                   noarch                           2.6-6.el6                                     base                           715 k

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

Total download size: 2.5 M
Installed size: 13 M

11. Update group

Just like the yum update, yum groupupdate will update the packages in the group.

[root@server ~]# yum groupupdate “Network file system client”
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.someimage.com
* extras: mirror.es.its.nyu.edu
* updates: centos.gravityfish.com
Setting up Group Process
Checking for new repos for mirrors
Resolving Dependencies
–> Running transaction check
—> Package autofs.x86_64 1:5.0.5-88.el6 will be installed
–> Processing Dependency: libhesiod.so.0()(64bit) for package: 1:autofs-5.0.5-88.el6.x86_64
–> Running transaction check
—> Package hesiod.x86_64 0:3.1.0-19.el6 will be installed
—> Package keyutils.x86_64 0:1.4-4.el6 will be installed
–> Processing Dependency: keyutils-libs = 1.4-4.el6 for package: keyutils-1.4-4.el6.x86_64
—> Package libtalloc.x86_64 0:2.0.1-1.1.el6 will be updated
—> Package libtalloc.x86_64 0:2.0.7-2.el6 will be an update
—> Package libtdb.x86_64 0:1.2.10-1.el6 will be installed
—> Package libtevent.x86_64 0:0.9.18-3.el6 will be installed
—> Package samba-common.x86_64 0:3.6.9-167.el6_5 will be installed
—> Package samba-winbind-clients.x86_64 0:3.6.9-167.el6_5 will be installed
–> Processing Dependency: samba-winbind = 3.6.9-167.el6_5 for package: samba-winbind-clients-3.6.9-167.el6_5.x86_64
–> Running transaction check
—> Package keyutils-libs.x86_64 0:1.4-1.el6 will be updated
—> Package keyutils-libs.x86_64 0:1.4-4.el6 will be an update
—> Package samba-winbind.x86_64 0:3.6.9-167.el6_5 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
Package                                          Arch                              Version                                    Repository                          Size
========================================================================================================================================================================
Installing:
autofs                                           x86_64                            1:5.0.5-88.el6                             base                               496 k
cifs-utils                                       x86_64                            4.8.1-19.el6                               base                                65 k
nfs4-acl-tools                                   x86_64                            0.3.3-6.el6                                base                                43 k
samba-client                                     x86_64                            3.6.9-167.el6_5                            updates                             11 M
samba-common                                     x86_64                            3.6.9-167.el6_5                            updates                             10 M
samba-winbind                                    x86_64                            3.6.9-167.el6_5                            updates                            2.1 M
samba-winbind-clients                            x86_64                            3.6.9-167.el6_5                            updates                            2.0 M
Updating for dependencies:
keyutils-libs                                    x86_64                            1.4-4.el6                                  base                                20 k
libtalloc                                        x86_64                            2.0.7-2.el6                                base                                20 k

Transaction Summary
========================================================================================================================================================================
Install      11 Package(s)
Upgrade       3 Package(s)

Total size: 26 M
Total download size: 26 M

12. Remove a group

Similar to yum remove, but here it is  removing an entire group.

[root@server ~]# yum groupremove “Malayalam Support [ml]”
Loaded plugins: fastestmirror
Setting up Group Process
Loading mirror speeds from cached hostfile
* base: centos.someimage.com
* extras: centos.mirror.constant.com
* updates: centos.gravityfish.com
No group named Malayalam Support [ml] exists
No packages to remove from groups
[root@server ~]# yum groupremove “Malayalam Support”
Loaded plugins: fastestmirror
Setting up Group Process
Loading mirror speeds from cached hostfile
* base: centos.someimage.com
* extras: centos.mirror.constant.com
* updates: mirrors.cmich.edu
Resolving Dependencies
–> Running transaction check
—> Package hunspell-ml.noarch 0:0.1-4.1.el6 will be erased
—> Package iok.x86_64 0:1.3.13-3.el6 will be erased
—> Package lohit-malayalam-fonts.noarch 0:2.4.4-5.el6 will be erased
—> Package m17n-contrib-malayalam.noarch 0:1.1.10-4.el6_1.1 will be erased
—> Package m17n-db-malayalam.noarch 0:1.5.5-1.1.el6 will be erased
—> Package samyak-malayalam-fonts.noarch 0:1.2.1-9.el6 will be erased
—> Package smc-anjalioldlipi-fonts.noarch 0:04.2-11.el6 will be erased
—> Package smc-dyuthi-fonts.noarch 0:04.2-11.el6 will be erased
—> Package smc-kalyani-fonts.noarch 0:04.2-11.el6 will be erased
—> Package smc-meera-fonts.noarch 0:04.2-11.el6 will be erased
—> Package smc-rachana-fonts.noarch 0:04.2-11.el6 will be erased
—> Package smc-raghumalayalam-fonts.noarch 0:04.2-11.el6 will be erased
—> Package smc-suruma-fonts.noarch 0:04.2-11.el6 will be erased
–> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
Package                                            Arch                             Version                                      Repository                       Size
========================================================================================================================================================================
Removing:
hunspell-ml                                        noarch                           0.1-4.1.el6                                  @base                           5.2 M
iok                                                x86_64                           1.3.13-3.el6                                 @base                           354 k
lohit-malayalam-fonts                              noarch                           2.4.4-5.el6                                  @base                            99 k
m17n-contrib-malayalam                             noarch                           1.1.10-4.el6_1.1                             @base                            63 k
m17n-db-malayalam                                  noarch                           1.5.5-1.1.el6                                @base                           7.3 k
samyak-malayalam-fonts                             noarch                           1.2.1-9.el6                                  @base                            45 k
smc-anjalioldlipi-fonts                            noarch                           04.2-11.el6                                  @base                           432 k
smc-dyuthi-fonts                                   noarch                           04.2-11.el6                                  @base                           204 k
smc-kalyani-fonts                                  noarch                           04.2-11.el6                                  @base                            81 k
smc-meera-fonts                                    noarch                           04.2-11.el6                                  @base                           328 k
smc-rachana-fonts                                  noarch                           04.2-11.el6                                  @base                           375 k
smc-raghumalayalam-fonts                           noarch                           04.2-11.el6                                  @base                            55 k
smc-suruma-fonts                                   noarch                           04.2-11.el6                                  @base                           461 k

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

Installed size: 7.6 M

13. Display current yum repositories

yum repolist will list the currently enabled repositories, but it wont display any of the disabled entries.

[root@server ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.lga7.us.voxel.net
* extras: centos.mirror.constant.com
* updates: mirrors.cmich.edu
repo id                                                                    repo name                                                                              status
base                                                                       CentOS-6 – Base                                                                        6,367
extras                                                                     CentOS-6 – Extras                                                                         14
updates                                                                    CentOS-6 – Updates                                                                       518
repolist: 6,899

14. List all the repositories including disabled

[root@server ~]# yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.someimage.com
* extras: centos.mirror.constant.com
* updates: centos.gravityfish.com
repo id                                                                 repo name                                                                         status
base                                                                    CentOS-6 – Base                                                                   enabled: 6,367
c6-media                                                                CentOS-6 – Media                                                                  disabled
centosplus                                                              CentOS-6 – Plus                                                                   disabled
contrib                                                                 CentOS-6 – Contrib                                                                disabled
debug                                                                   CentOS-6 – Debuginfo                                                              disabled
extras                                                                  CentOS-6 – Extras                                                                 enabled:    14
updates                                                                 CentOS-6 – Updates                                                                enabled:   518

15. List only Disabled repos.

[root@server ~]# yum repolist disabled
Loaded plugins: fastestmirror
repo id                                                                        repo name
c6-media                                                                       CentOS-6 – Media
centosplus                                                                     CentOS-6 – Plus
contrib                                                                        CentOS-6 – Contrib
debug                                                                          CentOS-6 – Debuginfo
repolist: 0

In the other way, yum repolist enabled will print only enabled repos.

[root@server ~]# yum repolist enabled
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.someimage.com
* extras: centos.mirror.constant.com
* updates: centos.gravityfish.com
repo id                                                                    repo name                                                                              status
base                                                                       CentOS-6 – Base                                                                        6,367
extras                                                                     CentOS-6 – Extras                                                                         14
updates                                                                    CentOS-6 – Updates                                                                       518
repolist: 6,899

16. Install from a disabled repositories

By default yum installs only from the enabled repositories.  use –enablerepo option in the ‘yum install’ if we want to specifically install a package from a disabled repository.

[root@server ~]# yum –enablerepo=centosplus install vim-X11.x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.lga7.us.voxel.net
* centosplus: mirrors.seas.harvard.edu
* extras: centos.mirror.constant.com
* updates: centos.gravityfish.com
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package vim-X11.x86_64 2:7.2.411-1.8.el6 will be installed
–> Processing Dependency: vim-common = 2:7.2.411-1.8.el6 for package: 2:vim-X11-7.2.411-1.8.el6.x86_64
–> Running transaction check
—> Package vim-common.x86_64 2:7.2.411-1.6.el6 will be updated
–> Processing Dependency: vim-common = 2:7.2.411-1.6.el6 for package: 2:vim-enhanced-7.2.411-1.6.el6.x86_64
—> Package vim-common.x86_64 2:7.2.411-1.8.el6 will be an update

17. YUM Interactive shell

[root@server ~]# yum shell
Loaded plugins: fastestmirror
Setting up Yum Shell
> info httpd
Loading mirror speeds from cached hostfile
* base: mirrors.lga7.us.voxel.net
* extras: centos.mirror.constant.com
* updates: centos.gravityfish.com
Available Packages
Name        : httpd
Arch        : x86_64
Version     : 2.2.15
Release     : 29.el6.centos
Size        : 821 k
Repo        : base
Summary     : Apache HTTP Server
URL         : http://httpd.apache.org/
License     : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and extensible
: web server.

18. Check the dependency of a package

[root@server ~]# yum deplist postfix
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.lga7.us.voxel.net
* extras: centos.mirror.constant.com
* updates: centos.gravityfish.com
Finding dependencies:
package: postfix.x86_64 2:2.6.6-2.2.el6_1
dependency: libssl.so.10()(64bit)
provider: openssl.x86_64 1.0.1e-15.el6
provider: openssl.x86_64 1.0.1e-16.el6_5
provider: openssl.x86_64 1.0.1e-16.el6_5.4
provider: openssl.x86_64 1.0.1e-16.el6_5.1
dependency: /usr/sbin/groupadd
provider: shadow-utils.x86_64 2:4.1.4.2-13.el6
dependency: /usr/sbin/useradd
provider: shadow-utils.x86_64 2:4.1.4.2-13.el6

19. Reinstall a yum package:

# yum reinstall PACKAGE_NAME

20. Create yum metadata

yum makecache is used to download and make usable all the metadata for the currently enabled yum repos. This is useful if you want to make sure the cache is fully current with all metadata before continuing.

# yum makecache

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.us.leaseweb.net
* extras: mirror.ash.fastserv.com
* updates: mirrors.lga7.us.voxel.net
Error: No matching Packages to list
[root@server ~]# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.us.leaseweb.net
* extras: mirror.ash.fastserv.com
* updates: mirrors.lga7.us.voxel.net
base                                                                                                                                             | 3.7 kB     00:00
base/other_db                                                                                                                                    | 2.8 MB     00:00
extras                                                                                                                                           | 3.4 kB     00:00
extras/prestodelta                                                                                                                               |  907 B     00:00
extras/other_db                                                                                                                                  | 5.8 kB     00:00
updates                                                                                                                                          | 3.4 kB     00:00
updates/filelists_db                                                                                                                             | 1.4 MB     00:00
updates/prestodelta                                                                                                                              | 145 kB     00:00
updates/other_db                                                                                                                                 | 225 kB     00:00
Metadata Cache Created

Cleaning the yum data

During its normal use yum creates a cache of metadata and packages. This cache can take up a lot of space.
The yum clean command allows you to clean up these files. All the files yum clean will act on are normally stored in /var/cache/yum.

21. yum clean packages
This cleans up any cached packages in any enabled repository cache directory.

[root@server ~]# yum clean packages
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
340 package files removed

22. yum clean metadata

This cleans up any xml metadata that may have been cached from any enabled repository.

[root@server ~]# yum clean metadata
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
13 metadata files removed
9 sqlite files removed
0 metadata files removed

23. yum clean dbcache

Yum will create or download some sqlite database files as part of its normal operation. This command clean up the cached copies of those from any enabled repository cache.

[root@server ~]# yum clean dbcache
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
0 sqlite files removed

24. yum clean all

Clean all cached files from any enabled repository. Useful to run from time to time to make sure there is nothing using unnecessary space.

[root@server ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up Everything
Cleaning up list of fastest mirrors

25. yum list extras

This command lists any installed package which no longer appears in any of your enabled repositories.
Useful for finding packages which linger between upgrades or things installed not from a repo.

[root@server ~]# yum list extras
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.us.leaseweb.net
* extras: mirror.ash.fastserv.com
* updates: mirrors.lga7.us.voxel.net
Extra Packages
Red_Hat_Enterprise_Linux-Release_Notes-6-en-US.noarch    1-26.el6                                 @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
abrt.x86_64                                              1.1.16-3.el6                             @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
abrt-addon-ccpp.x86_64                                   1.1.16-3.el6                             @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
abrt-addon-kerneloops.x86_64                             1.1.16-3.el6                             @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
abrt-addon-python.x86_64                                 1.1.16-3.el6                             @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
abrt-cli.x86_64                                          1.1.16-3.el6                             @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
abrt-libs.x86_64                                         1.1.16-3.el6                             @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
abrt-plugin-logger.x86_64                                1.1.16-3.el6                             @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
abrt-plugin-mailx.x86_64                                 1.1.16-3.el6                             @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
abrt-plugin-rhtsupport.x86_64                            1.1.16-3.el6                             @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
……………………………………………………………………………………………………………
……………………………………………………………………………………..

26. yum list obsoletes

This command lists any obsoleting relationships between any available package and any installed package.

[root@server ~]# yum list obsoletes
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.us.leaseweb.net
* extras: mirror.ash.fastserv.com
* updates: mirrors.lga7.us.voxel.net
Obsoleting Packages
abrt.x86_64                                                     2.0.8-21.el6.centos                              base
abrt-plugin-sosreport.x86_64                                1.1.16-3.el6                                     @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
libjpeg-turbo.x86_64                                            1.2.1-3.el6_5                                    updates
libjpeg.x86_64                                              6b-46.el6                                        @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
libreport-plugin-logger.x86_64                                  2.0.9-19.el6.centos                              base
abrt-plugin-logger.x86_64                                   1.1.16-3.el6                                     @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
libreport-plugin-mailx.x86_64                                   2.0.9-19.el6.centos                              base
abrt-plugin-mailx.x86_64                                    1.1.16-3.el6                                     @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1
libreport-plugin-rhtsupport.x86_64                              2.0.9-19.el6.centos                              base
abrt-plugin-rhtsupport.x86_64                               1.1.16-3.el6                                     @anaconda-RedHatEnterpriseLinux-201105101844.x86_64/6.1

27. yum list updates

This command lists any package in an enabled repository which is an update for any installed package.

[root@server ~]# yum list updates
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.us.leaseweb.net
* extras: mirror.ash.fastserv.com
* updates: mirrors.lga7.us.voxel.net
Updated Packages
abrt.x86_64                                                                     2.0.8-21.el6.centos                                                              base
abrt-addon-ccpp.x86_64                                                          2.0.8-21.el6.centos                                                              base
abrt-addon-kerneloops.x86_64                                                    2.0.8-21.el6.centos                                                              base
abrt-addon-python.x86_64                                                        2.0.8-21.el6.centos                                                              base
abrt-cli.x86_64                                                                 2.0.8-21.el6.centos                                                              base
abrt-libs.x86_64                                                                2.0.8-21.el6.centos                                                              base
acl.x86_64                                                                      2.2.49-6.el6                                                                     base
alsa-lib.x86_64                                                                 1.0.22-3.el6                                                                     base
alsa-utils.x86_64                                                               1.0.22-5.el6                                                                     base
…………………………………………………………………………
…………………………………………………….

28. yum list recent

This command lists any package added to any enabled repository in the last seven(7) days.

[root@server ~]# yum list recent
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.us.leaseweb.net
* extras: mirror.ash.fastserv.com
* updates: mirrors.lga7.us.voxel.net
Recently Added Packages
mysql.x86_64                                                                      5.1.73-3.el6_5                                                                 updates
mysql-bench.x86_64                                                                5.1.73-3.el6_5                                                                 updates
mysql-devel.i686                                                                  5.1.73-3.el6_5                                                                 updates
mysql-devel.x86_64                                                                5.1.73-3.el6_5                                                                 updates
mysql-embedded.i686                                                               5.1.73-3.el6_5                                                                 updates
mysql-embedded.x86_64                                                             5.1.73-3.el6_5                                                                 updates
mysql-embedded-devel.i686                                                         5.1.73-3.el6_5                                                                 updates

28. yum –showduplicates (command) (package)

Doesn’t limit packages to their latest versions in the info, list and search commands

[root@server ~]# yum –showduplicates list firefox
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.us.leaseweb.net
* extras: mirror.ash.fastserv.com
* updates: mirrors.lga7.us.voxel.net
Available Packages
firefox.i686                                                                17.0.10-1.el6.centos                                                                 base
firefox.x86_64                                                              17.0.10-1.el6.centos                                                                 base
firefox.i686                                                                24.2.0-1.el6.centos                                                                  updates
firefox.x86_64                                                              24.2.0-1.el6.centos                                                                  updates
firefox.i686                                                                24.2.0-1.0.1.el6.centos                                                              updates
firefox.x86_64                                                              24.2.0-1.0.1.el6.centos                                                              updates
firefox.i686                                                                24.2.0-6.el6.centos                                                                  updates
firefox.x86_64                                                              24.2.0-6.el6.centos                                                                  updates
firefox.i686                                                                24.3.0-2.el6.centos                                                                  updates
firefox.x86_64                                                              24.3.0-2.el6.centos                                                                  updates

29. yum downgrade

Will try and downgrade a package from the version currently installed to the previously highest version (or the specified version). The depsolver will not necessarily work, but if you specify all the packages it should work (and thus. all the simple cases will work). Also this does not work for “installonly” packages, like Kernels. downgrade operates on groups, files, provides and filelists just like the “install” command.

For example, the current firefox version installed is 24.2.0-6.el6.centos and lets see what happens if we downgrade it.

[root@server ~]# yum downgrade firefox
Loaded plugins: fastestmirror
Setting up Downgrade Process
Loading mirror speeds from cached hostfile
* base: mirror.us.leaseweb.net
* extras: mirror.ash.fastserv.com
* updates: mirrors.lga7.us.voxel.net
Resolving Dependencies
–> Running transaction check
—> Package firefox.x86_64 0:24.2.0-1.0.1.el6.centos will be a downgrade
—> Package firefox.x86_64 0:24.2.0-6.el6.centos will be erased
–> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
Package                             Arch                               Version                                               Repository                           Size
========================================================================================================================================================================
Downgrading:
firefox                             x86_64                             24.2.0-1.0.1.el6.centos                               updates                              47 M

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

YUM HISTORY

The history command allows an admin to access detailed information on the history of yum transactions that have been run on a system.

30. yum history

[root@server ~]# yum history
Loaded plugins: fastestmirror
ID     | Login user               | Date and time    | Action(s)      | Altered
——————————————————————————-
19 | root <root>              | 2014-02-19 14:28 | Downgrade      |    1
18 | root <root>              | 2014-02-19 14:27 | Downgrade      |    1
17 | root <root>              | 2014-02-19 14:26 | I, U           |   13
16 | root <root>              | 2014-02-17 18:42 | Install        |   20
15 | root <root>              | 2014-02-17 18:04 | Update         |    3
14 | root <root>              | 2014-02-17 18:00 | Erase          |    1
13 | root <root>              | 2014-02-17 17:56 | Install        |    1 P<
12 | root <root>              | 2013-06-26 14:38 | Install        |    1 >
11 | root <root>              | 2013-06-26 14:38 | Install        |    1
10 | root <root>              | 2013-06-26 14:38 | Install        |    1
9 | root <root>              | 2013-06-26 14:37 | Install        |    1 EE

31. yum history summary

List summary of all all past transactions

[root@server ~]# yum history summary
Loaded plugins: fastestmirror
Login user                 | Time                | Action(s)        | Altered
——————————————————————————-
root <root>                | Last day            | D, I, U          |       15
root <root>                | Last week           | E, I, U          |       25
root <root>                | Last year           | Install          |        9
System <unset>             | Over a year ago     | I, U             |      466
root <root>                | Over a year ago     | Install          |        1
history summary

32. yum history list <package>

Find out history of a specific package

[root@server ~]# yum history list firefox
Loaded plugins: fastestmirror
ID     | Login user               | Date and time    | Action(s)      | Altered
——————————————————————————-
19 | root <root>              | 2014-02-19 14:28 | Downgrade      |    1
18 | root <root>              | 2014-02-19 14:27 | Downgrade      |    1
17 | root <root>              | 2014-02-19 14:26 | I, U           |   13
history list

33. yum history package-list <package name>

If you need a detailed history list of a package with the version name.

[root@server ~]# yum history package-list firefox
Loaded plugins: fastestmirror
ID     | Action(s)      | Package
——————————————————————————-
19 | Downgrade      | firefox-24.2.0-1.0.1.el6.centos.x86_64
19 | Downgraded     |         24.2.0-6.el6.centos.x86_64
18 | Downgrade      | firefox-24.2.0-6.el6.centos.x86_64
18 | Downgraded     |         24.3.0-2.el6.centos.x86_64
17 | Install        | firefox-24.3.0-2.el6.centos.x86_64
history package-list

34. yum history info <id>

[root@server ~]# yum history info 19
Loaded plugins: fastestmirror
Transaction ID : 19
Begin time     : Wed Feb 19 14:28:23 2014
Begin rpmdb    : 498:8f4c362ec40f5a399253c7c9454e0647a270b5b1
End time       :            14:28:31 2014 (8 seconds)
End rpmdb      : 498:18537b2b28a849d97deaa89bf4c40769219645fe
User           : root <root>
Return-Code    : Success
Command Line   : downgrade firefox
Transaction performed with:
Installed     rpm-4.8.0-16.el6.x86_64
Installed     yum-3.2.29-17.el6.centos.noarch
Installed     yum-plugin-fastestmirror-1.1.30-6.el6.noarch
Packages Altered:
Downgrade  firefox-24.2.0-1.0.1.el6.centos.x86_64
Downgraded         24.2.0-6.el6.centos.x86_64

35. yum erase <package>

Same as yum remove, it will un-install the package.

[root@server ~]# yum erase firefox
Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
–> Running transaction check
—> Package firefox.x86_64 0:24.2.0-1.0.1.el6.centos will be erased
–> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
Package                             Arch                               Version                                              Repository                            Size
========================================================================================================================================================================
Removing:
firefox                             x86_64                             24.2.0-1.0.1.el6.centos                              @updates                              80 M

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

Installed size: 80 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing    : firefox-24.2.0-1.0.1.el6.centos.x86_64                                                                                                               1/1

Removed:
firefox.x86_64 0:24.2.0-1.0.1.el6.centos

Complete!

36. yum history undo <id>

Undo a yum history action, which is very importan when we have to roll back certain changes in the production.

[root@server ~]# yum history pkgs-list firefox
Loaded plugins: fastestmirror
ID     | Action(s)      | Package
——————————————————————————-
20 | Erase          | firefox-24.2.0-1.0.1.el6.centos.x86_64
19 | Downgrade      | firefox-24.2.0-1.0.1.el6.centos.x86_64
19 | Downgraded     |         24.2.0-6.el6.centos.x86_64
18 | Downgrade      | firefox-24.2.0-6.el6.centos.x86_64
18 | Downgraded     |         24.3.0-2.el6.centos.x86_64
17 | Install        | firefox-24.3.0-2.el6.centos.x86_64
history pkgs-list

Now, here is the undo part !

[root@server ~]# yum history undo 20
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.us.leaseweb.net
* extras: mirror.ash.fastserv.com
* updates: mirrors.lga7.us.voxel.net
Undoing transaction 20, from Wed Feb 19 14:58:03 2014
Erase firefox-24.2.0-1.0.1.el6.centos.x86_64
Resolving Dependencies
–> Running transaction check
—> Package firefox.x86_64 0:24.2.0-1.0.1.el6.centos will be installed
–> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
Package                             Arch                               Version                                               Repository                           Size
========================================================================================================================================================================
Installing:
firefox                             x86_64                             24.2.0-1.0.1.el6.centos                               updates                              47 M

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

Total download size: 47 M
Installed size: 80 M

37. yum history redo <id>

To repeat a particular transaction , that is the opposite of what we have done above.

38. yum history rollback <id>

The rollback command will undo all transactions up to the point of the specified transaction.

39. yum history new

yum stores the transaction history in a single SQLite database file in /var/lib/yum/history/ directory.
“yum history new”  will start new transaction history.

[root@server ~]# yum history new
Loaded plugins: fastestmirror
history new
[root@server ~]#
[root@server ~]# yum history list all
Loaded plugins: fastestmirror
No transactions
Error: Failed history list

Hope you have enjoyed our post about the Ultimate yum commands. Stay tuned !