Chapter 9. Yum
Important
Note
su or sudo command.
9.1. Checking For and Updating Packages
9.1.1. Checking For Updates
yumcheck-update
Example 9.1. Example output of the yum check-update command
yum check-update can look as follows:
~]# yum check-update
Loaded plugins: product-id, search-disabled-repos, subscription-manager
dracut.x86_64 033-360.el7_2 rhel-7-server-rpms
dracut-config-rescue.x86_64 033-360.el7_2 rhel-7-server-rpms
kernel.x86_64 3.10.0-327.el7 rhel-7-server-rpms
rpm.x86_64 4.11.3-17.el7 rhel-7-server-rpms
rpm-libs.x86_64 4.11.3-17.el7 rhel-7-server-rpms
rpm-python.x86_64 4.11.3-17.el7 rhel-7-server-rpms
yum.noarch 3.4.3-132.el7 rhel-7-server-rpmsdracut— the name of the package,x86_64— the CPU architecture the package was built for,033— the version of the updated package to be installed,360.el7— the release of the updated package,_2— a build version, added as part of a z-stream update,rhel-7-server-rpms— the repository in which the updated package is located.
yum command.
9.1.2. Updating Packages
Updating a Single Package
root:
yumupdatepackage_name
Example 9.2. Updating the rpm package
~]# yum update rpm
Loaded plugins: langpacks, product-id, subscription-manager
Updating Red Hat repositories.
INFO:rhsm-app.repolib:repos updated: 0
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package rpm.x86_64 0:4.11.1-3.el7 will be updated
--> Processing Dependency: rpm = 4.11.1-3.el7 for package: rpm-libs-4.11.1-3.el7.x86_64
--> Processing Dependency: rpm = 4.11.1-3.el7 for package: rpm-python-4.11.1-3.el7.x86_64
--> Processing Dependency: rpm = 4.11.1-3.el7 for package: rpm-build-4.11.1-3.el7.x86_64
---> Package rpm.x86_64 0:4.11.2-2.el7 will be an update
--> Running transaction check
...
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Updating:
rpm x86_64 4.11.2-2.el7 rhel 1.1 M
Updating for dependencies:
rpm-build x86_64 4.11.2-2.el7 rhel 139 k
rpm-build-libs x86_64 4.11.2-2.el7 rhel 98 k
rpm-libs x86_64 4.11.2-2.el7 rhel 261 k
rpm-python x86_64 4.11.2-2.el7 rhel 74 k
Transaction Summary
=============================================================================
Upgrade 1 Package (+4 Dependent packages)
Total size: 1.7 M
Is this ok [y/d/N]:
Loaded plugins: langpacks, product-id, subscription-manager— Yum always informs you which yum plug-ins are installed and enabled. See Section 9.6, “Yum Plug-ins” for general information on yum plug-ins, or Section 9.6.3, “Working with Yum Plug-ins” for descriptions of specific plug-ins.rpm.x86_64— you can download and install a new rpm package as well as its dependencies. Transaction check is performed for each of these packages.- Yum presents the update information and then prompts you for confirmation of the update; yum runs interactively by default. If you already know which transactions the
yumcommand plans to perform, you can use the-yoption to automatically answeryesto any questions that yum asks (in which case it runs non-interactively). However, you should always examine which changes yum plans to make to the system so that you can easily troubleshoot any problems that might arise. You can also choose to download the package without installing it. To do so, select thedoption at the download prompt. This launches a background download of the selected package.If a transaction fails, you can view yum transaction history by using theyum historycommand as described in Section 9.4, “Working with Transaction History”.
Important
yum update or yum install command.
rpm -i kernel command which installs a new kernel instead of rpm -u kernel which replaces the current kernel.
root:
yum group update group_nameupgrade command that is equal to update with enabled obsoletes configuration option (see Section 9.5.1, “Setting [main] Options”). By default, obsoletes is turned on in /etc/yum.conf, which makes these two commands equivalent.
Updating All Packages and Their Dependencies
yum update command without any arguments:
yum updateUpdating Security-Related Packages
root:
yum update --securityroot:
yum update-minimal --security- the kernel-3.10.0-1 package is installed on your system;
- the kernel-3.10.0-2 package was released as a security update;
- the kernel-3.10.0-3 package was released as a bug fix update.
yum update-minimal --security updates the package to kernel-3.10.0-2, and yum update --security updates the package to kernel-3.10.0-3.
Automating Package Updating
yum-cron service. For more information, see Section 9.7, “Automatically Refreshing Package Database and Downloading Updates with Yum-cron”.
9.1.3. Upgrading the System Off-line with ISO and Yum
yum update command with the Red Hat Enterprise Linux installation ISO image is an easy and quick way to upgrade systems to the latest minor version. The following steps illustrate the upgrading process:
- Create a target directory to mount your ISO image. This directory is not automatically created when mounting, so create it before proceeding to the next step. As
root, type:mkdirmount_dirReplace mount_dir with a path to the mount directory. Typically, users create it as a subdirectory in the/mediadirectory. - Mount the Red Hat Enterprise Linux 7 installation ISO image to the previously created target directory. As
root, type:mount-oloopiso_name mount_dirReplace iso_name with a path to your ISO image and mount_dir with a path to the target directory. Here, the-oloopoption is required to mount the file as a block device. - Copy the
media.repofile from the mount directory to the/etc/yum.repos.d/directory. Note that configuration files in this directory must have the .repo extension to function properly.cpmount_dir/media.repo/etc/yum.repos.d/new.repoThis creates a configuration file for the yum repository. Replace new.repo with the filename, for example rhel7.repo. - Edit the new configuration file so that it points to the Red Hat Enterprise Linux installation ISO. Add the following line into the
/etc/yum.repos.d/new.repofile:baseurl=file:///mount_dir
Replace mount_dir with a path to the mount point. - Update all yum repositories including
/etc/yum.repos.d/new.repocreated in previous steps. Asroot, type:yumupdateThis upgrades your system to the version provided by the mounted ISO image. - After successful upgrade, you can unmount the ISO image. As
root, type:umountmount_dirwhere mount_dir is a path to your mount directory. Also, you can remove the mount directory created in the first step. Asroot, type:rmdirmount_dir - If you will not use the previously created configuration file for another installation or update, you can remove it. As
root, type:rm/etc/yum.repos.d/new.repo
Example 9.3. Upgrading from Red Hat Enterprise Linux 7.0 to 7.1
rhel-server-7.1-x86_64-dvd.iso, create a target directory for mounting, such as /media/rhel7/. As root, change into the directory with your ISO image and type:
~]#mount-olooprhel-server-7.1-x86_64-dvd.iso/media/rhel7/
media.repo file from the mount directory:
~]#cp/media/rhel7/media.repo/etc/yum.repos.d/rhel7.repo
/etc/yum.repos.d/rhel7.repo copied in the previous step:
baseurl=file:///media/rhel7/
rhel-server-7.1-x86_64-dvd.iso. As root, execute:
~]#yumupdate
~]#umount/media/rhel7/
~]#rmdir/media/rhel7/
~]#rm/etc/yum.repos.d/rhel7.repo

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.