Bookmark this page

Managing Software Updates with yum

yum is used to install and update software packages.

Objectives

After completing this section, students should be able to find, install, and update software packages using the yum command.

Working with yum

Using yum

yum is a powerful command-line tool that can be used to more flexibly manage (install, update, remove, and query) software packages. Official Red Hat packages are normally downloaded from Red Hat's content distribution network. Registering a system to the subscription management service automatically configures access to software repositories based on the attached subscriptions.

Finding software with yum

  • yum help will display usage information.

  • yum list displays installed and available packages.

    [root@serverX ~]# yum list 'http*'
    Loaded plugins: langpacks
    Available Packages
    httpcomponents-client.noarch                4.2.5-4.el7                 rhel_dvd
    httpcomponents-core.noarch                  4.2.4-6.el7                 rhel_dvd
    httpd.x86_64                                2.4.6-17.el7                rhel_dvd
    httpd-devel.x86_64                          2.4.6-17.el7                rhel_dvd
    httpd-manual.noarch                         2.4.6-17.el7                rhel_dvd
    httpd-tools.x86_64                          2.4.6-17.el7                rhel_dvd
    
  • yum search KEYWORD lists packages by keywords found in the name and summary fields only.

    To search for packages that have "web server" in their name, summary, and description fields, use search all:

    [root@serverX ~]# yum search all 'web server'
    Loaded plugins: langpacks
    ============================= Matched: web server ==============================
    freeradius.x86_64 : High-performance and highly configurable free RADIUS server
    hsqldb.noarch : HyperSQL Database Engine
    httpd.x86_64 : Apache HTTP Server
    libcurl.i686 : A library for getting files from web servers
    libcurl.x86_64 : A library for getting files from web servers
    mod_revocator.x86_64 : CRL retrieval module for the Apache HTTP server
    mod_security.x86_64 : Security module for the Apache HTTP Server
    python-paste.noarch : Tools for using a Web Server Gateway Interface stack
    
  • yum info PACKAGENAME gives detailed information about a package, including the disk space needed for installation.

    To get information on the Apache HTTP Server:

    [root@serverX ~]# yum info httpd
    Loaded plugins: langpacks
    Available Packages
    Name        : httpd
    Arch        : x86_64
    Version     : 2.4.6
    Release     : 17.el7
    Size        : 1.1 M
    Repo        : rhel_dvd
    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.
    
  • yum provides PATHNAME displays packages that match the pathname specified (which often include wildcard characters).

    To find packages that provide the /var/www/html directory, use:

    [root@serverX ~]# yum provides /var/www/html
    Loaded plugins: langpacks
    httpd-2.4.6-17.el7.x86_64 : Apache HTTP Server
    Repo        : rhel_dvd
    Matched from:
    Filename    : /var/www/html
    
    
    
    1:php-pear-1.9.4-21.el7.noarch : PHP Extension and Application Repository
                                   : framework
    Repo        : rhel_dvd
    Matched from:
    Filename    : /var/www/html
    

Installing and removing software with yum

  • yum install PACKAGENAME obtains and installs a software package, including any dependencies.

    [root@serverX ~]# yum install httpd
    Loaded plugins: langpacks
    Resolving Dependencies
    --> Running transaction check
    ---> Package httpd.x86_64 0:2.4.6-17.el7 will be installed
    --> Processing Dependency: httpd-tools = 2.4.6-17.el7 for package: httpd-2.4.6-17.el7.x86_64
    --> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-17.el7.x86_64
    --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-17.el7.x86_64
    --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-17.el7.x86_64
    --> Running transaction check
    ---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
    ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
    ---> Package httpd-tools.x86_64 0:2.4.6-17.el7 will be installed
    ---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ================================================================================
     Package             Arch           Version              Repository        Size
    ================================================================================
    Installing:
     httpd               x86_64         2.4.6-17.el7         rhel_dvd         1.1 M
    Installing for dependencies:
     apr                 x86_64         1.4.8-3.el7          rhel_dvd         100 k
     apr-util            x86_64         1.5.2-6.el7          rhel_dvd          90 k
     httpd-tools         x86_64         2.4.6-17.el7         rhel_dvd          76 k
     mailcap             noarch         2.1.41-2.el7         rhel_dvd          31 k
    
    Transaction Summary
    ================================================================================
    Install  1 Package (+4 Dependent packages)
    
    Total download size: 1.4 M
    Installed size: 4.3 M
    Is this ok [y/d/N]: 
    
  • yum update PACKAGENAME obtains and installs a newer version of the software package, including any dependencies. Generally the process tries to preserve configuration files in place, but in some cases, they may be renamed if the packager thinks the old one will not work after the update. With no PACKAGENAME specified, it will install all relevant updates.

    [root@serverX ~]# yum update

    Since a new kernel can only be tested by booting to that kernel, the package is specifically designed so that multiple versions may be installed at once. If the new kernel fails to boot, the old kernel is still available. Using yum update kernel will actually install the new kernel. The configuration files hold a list of packages to "always install" even if the administrator requests an update.

    Note

    Use yum list kernel to list all installed and available kernels. To view the currently running kernel, use the uname command. The -r option will show only the kernel version and release, and the -a option will show the kernel release and additional information.

    [root@serverX ~]# yum list kernel
    Loaded plugins: langpacks
    Installed Packages
    kernel.x86_64             3.10.0-123.0.1.el7             @anaconda/7.0          
    kernel.x86_64             3.10.0-84.el7                  @rhel-7-server-htb-rpms
    [root@serverX ~]# uname -r
    3.10.0-123.el7.x86_64
    [root@serverX ~]# uname -a
    Linux demo.example.com 3.10.0-123.el7.x86_64 #1 SMP Tue Nov 26 16:51:22 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
    	
  • yum remove PACKAGENAME removes an installed software package, including any supported packages.

    [root@serverX ~]# yum remove httpd

    Warning

    yum remove will remove the package(s) listed and any package that requires the package(s) being removed (and package(s) which require those packages, and so on). This can lead to unexpected removal of packages, so carefully check the list of packages to be removed.

Installing and removing groups of software with yum

  • yum also has the concept of groups, which are collections of related software installed together for a particular purpose. In Red Hat Enterprise Linux 7, there are two kinds of groups. Regular groups are collections of packages. Environment groups are collections of other groups which include their own packages. The packages or groups provided by a group may be mandatory (must be installed if the group is installed), default (are normally installed if the group is installed), or optional (are not installed when the group is unless asked for specifically).

    Like yum list, the yum group list (or yum grouplist) command will show the names of installed and available groups. Some groups are normally installed through environment groups and are hidden by default. These hidden groups can also be listed with the yum group list hidden command. If the ids option is added, the group ID will also be shown. Groups can be installed, updated, removed, and otherwise queried by name or ID.

    [root@serverX ~]# yum group list
    Loaded plugins: langpacks
    Available environment groups:
       Minimal install
       Infrastructure Server
       File and Print Server
       Web Server
       Virtualization Host
       Server with GUI
    Installed groups:
       Base
       Desktop Debugging and Performance Tools
       Dial-up Networking Support
       Fonts
       Input Methods
       Internet Browser
       PostgreSQL Database server
       Printing client
       X Window System
    Available Groups:
       Additional Development
       Backup Client
       Backup Server
    ...
  • Information about a group is displayed with yum group info (or yum groupinfo). It includes a list of mandatory, default, and optional package names or group IDs. The package names or group IDs may have a marker in front of them.

    MarkerMeaning
    =Package is installed, was installed as part of the group
    +Package isn't installed, will be if the group is installed or updated
    -Package isn't installed, will not be if the group is installed or updated
    no markerPackage is installed, but was not installed through the group.
    [root@serverX ~]# yum group info "Identity Management Server"
    Loaded plugins: langpacks
    
    Group: Identity Management Server
     Group-Id: identity-management-server
     Description: Centralized management of users, servers and authentication policies.
     Default Packages:
       +389-ds-base
       +ipa-admintools
       +ipa-server
       +pki-ca
     Optional Packages:
       +ipa-server-trust-ad
       +nuxwdog
       +slapi-nis
    
  • The yum group install (or yum groupinstall) command will install a group which will install its mandatory and default packages and the packages they depend on.

    [root@serverX ~]# yum group install "Infiniband Support"
    ...
    Transaction Summary
    ================================================================================
    Install  17 Packages (+7 Dependent packages)
    
    Total download size: 9.0 M
    Installed size: 33 M
    Is this ok [y/d/N]:
    ...

Important

The behavior of yum groups has changed in Red Hat Enterprise Linux 7 from Red Hat Enterprise Linux 6 and earlier. In RHEL 7, groups are treated as objects, and are tracked by the system. If an installed group is updated, and new mandatory or default packages have been added to the group by the yum repository, those new packages will be installed on update.

RHEL 6 and earlier consider a group to be installed if all its mandatory packages have been installed; or if it had no mandatory packages, if any default or optional packages in the group are installed. In RHEL 7, a group is considered to be installed only if yum group install was used to install it. A new command in RHEL 7, yum group mark install GROUPNAME can be used to mark a group as installed, and any missing packages and their dependencies will be installed on the next update.

Finally, RHEL 6 and earlier did not have the two-word form of the yum group commands. In other words, in RHEL 6 the command yum grouplist existed, but the equivalent RHEL 7 command yum group list did not.

Viewing transaction history

  • All install and remove transactions are logged in /var/log/yum.log.

    [root@serverX ~]# tail -5 /var/log/yum.log
    Feb 16 14:10:41 Installed: libnes-1.1.3-5.el7.x86_64
    Feb 16 14:10:42 Installed: libmthca-1.0.6-10.el7.x86_64
    Feb 16 14:10:43 Installed: libmlx4-1.0.5-7.el7.x86_64
    Feb 16 14:10:43 Installed: libibcm-1.0.5-8.el7.x86_64
    Feb 16 14:10:45 Installed: rdma-7.0_3.13_rc8-3.el7.noarch
    
  • A summary of install and remove transactions can be viewed with yum history.

    [root@serverX ~]# yum history
    Loaded plugins: langpacks
    ID     | Login user               | Date and time    | Action(s)      | Altered
    -------------------------------------------------------------------------------
         6 | Student User <student>   | 2014-02-16 14:09 | Install        |   25   
         5 | Student User <student>   | 2014-02-16 14:01 | Install        |    1   
         4 | System <unset>           | 2014-02-08 22:33 | Install        | 1112 EE
         3 | System <unset>           | 2013-12-16 13:13 | Erase          |    4   
         2 | System <unset>           | 2013-12-16 13:13 | Erase          |    1   
         1 | System <unset>           | 2013-12-16 13:08 | Install        |  266   
    history list
    
  • A transaction can be reversed with the history undo options:

    [root@serverX ~]# yum history undo 6
    Loaded plugins: langpacks
    Undoing transaction 6, from Sun Feb 16 14:09:51 2014
        Install     dapl-2.0.39-2.el7.x86_64              @rhel-7-server-htb-rpms
        Dep-Install graphviz-2.30.1-18.el7.x86_64         @rhel-7-server-htb-rpms
        Dep-Install graphviz-tcl-2.30.1-18.el7.x86_64     @rhel-7-server-htb-rpms
        Install     ibacm-1.0.8-4.el7.x86_64              @rhel-7-server-htb-rpms
        Install     ibutils-1.5.7-9.el7.x86_64            @rhel-7-server-htb-rpms
        Dep-Install ibutils-libs-1.5.7-9.el7.x86_64       @rhel-7-server-htb-rpms   
    ...

Summary of yum commands

Packages can be located, installed, updated, and removed by name or by package groups.

Task:Command:
List installed and available packages by nameyum list [NAME-PATTERN]
List installed and available groupsyum grouplist
Search for a package by keywordyum search KEYWORD
Show details of a packageyum info PACKAGENAME
Install a packageyum install PACKAGENAME
Install a package groupyum groupinstall "GROUPNAME"
Update all packagesyum update
Remove a packageyum remove PACKAGENAME
Display transaction historyyum history

References

yum(1) and yum.conf(5) man pages

Additional information on yum may be available in the Red Hat Enterprise Linux System Administrator's Guide for Red Hat Enterprise Linux 7, which can be found at https://access.redhat.com/documentation/

Revision: rh124-7-1b00421