RHCSA Rapid Track
Objectives
After completing this section, you should be able to find, install, and update software packages, using the yum command.
Managing Software Packages with Yum
The low-level rpm command can be used to install packages, but it is not designed to work with package repositories or resolve dependencies from multiple sources automatically.
Yum is designed to be a better system for managing RPM-based software installation and updates. The yum command allows you to install, update, remove, and get information about software packages and their dependencies. You can get a history of transactions performed and work with multiple Red Hat and third-party software repositories.
Finding Software with Yum
yum help displays usage information.
yum list displays installed and available packages.
[user@host ~]$yum list 'http*'Available Packages http-parser.i686 2.8.0-2.el8 rhel8-appstream http-parser.x86_64 2.8.0-2.el8 rhel8-appstream httpcomponents-client.noarch 4.5.5-4.module+el8+2452+b359bfcd rhel8-appstream httpcomponents-core.noarch 4.4.10-3.module+el8+2452+b359bfcd rhel8-appstream httpd.x86_64 2.4.37-7.module+el8+2443+605475b7 rhel8-appstream httpd-devel.x86_64 2.4.37-7.module+el8+2443+605475b7 rhel8-appstream httpd-filesystem.noarch 2.4.37-7.module+el8+2443+605475b7 rhel8-appstream httpd-manual.noarch 2.4.37-7.module+el8+2443+605475b7 rhel8-appstream httpd-tools.x86_64 2.4.37-7.module+el8+2443+605475b7 rhel8-appstreamyum search
KEYWORDlists 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:
[user@host ~]$yum search all 'web server'================= Summary & Description Matched: web server ==================== pcp-pmda-weblog.x86_64 : Performance Co-Pilot (PCP) metrics from web server logs nginx.x86_64 : A high performance web server and reverse proxy server ======================== Summary Matched: web server =========================== libcurl.x86_64 : A library for getting files from web servers libcurl.i686 : A library for getting files from web servers libcurl.x86_64 : A library for getting files from web servers ====================== Description Matched: web server ========================= httpd.x86_64 : Apache HTTP Server git-instaweb.x86_64 : Repository browser in gitweb ...output omitted...yum info
PACKAGENAMEreturns detailed information about a package, including the disk space needed for installation.To get information on the Apache HTTP Server:
[user@host ~]$yum info httpdAvailable Packages Name : httpd Version : 2.4.37 Release : 7.module+el8+2443+605475b7 Arch : x86_64 Size : 1.4 M Source : httpd-2.4.37-7.module+el8+2443+605475b7.src.rpm Repo : rhel8-appstream Summary : Apache HTTP Server URL : https://httpd.apache.org/ License : ASL 2.0 Description : The Apache HTTP Server is a powerful, efficient, and extensible : web server.yum provides
PATHNAMEdisplays packages that match the path name specified (which often include wildcard characters).To find packages that provide the
/var/www/htmldirectory, use:[user@host ~]$yum provides /var/www/htmlhttpd-filesystem-2.4.37-7.module+el8+2443+605475b7.noarch : The basic directory layout for the Apache HTTP server Repo : rhel8-appstream Matched from: Filename : /var/www/html
Installing and removing software with yum
yum install
PACKAGENAMEobtains and installs a software package, including any dependencies.[user@host ~]$yum install httpdDependencies resolved. ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: httpd x86_64 2.4.37-7.module... rhel8-appstream 1.4 M Installing dependencies: apr x86_64 1.6.3-8.el8 rhel8-appstream 125 k apr-util x86_64 1.6.1-6.el8 rhel8-appstream 105 k ...output omitted... Transaction Summary ================================================================================ Install 9 Packages Total download size: 2.0 M Installed size: 5.4 M Is this ok [y/N]:yDownloading Packages: (1/9): apr-util-bdb-1.6.1-6.el8.x86_64.rpm 464 kB/s | 25 kB 00:00 (2/9): apr-1.6.3-8.el8.x86_64.rpm 1.9 MB/s | 125 kB 00:00 (3/9): apr-util-1.6.1-6.el8.x86_64.rpm 1.3 MB/s | 105 kB 00:00 ...output omitted... Total 8.6 MB/s | 2.0 MB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : apr-1.6.3-8.el8.x86_64 1/9 Running scriptlet: apr-1.6.3-8.el8.x86_64 1/9 Installing : apr-util-bdb-1.6.1-6.el8.x86_64 2/9 ...output omitted... Installed: httpd-2.4.37-7.module+el8+2443+605475b7.x86_64 apr-util-bdb-1.6.1-6.el8.x86_64 apr-util-openssl-1.6.1-6.el8.x86_64 apr-1.6.3-8.el8.x86_64 ...output omitted... Complete!yum update
PACKAGENAMEobtains and installs a newer version of the specified 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 installs all relevant updates.[user@host ~]$sudo yum updateSince 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 only shows the kernel version and release, and the -a option shows the kernel release and additional information.
[user@host ~]$yum list kernelInstalled Packages kernel.x86_64 4.18.0-60.el8 @anaconda kernel.x86_64 4.18.0-67.el8 @rhel-8-for-x86_64-baseos-htb-rpms[user@host ~]$uname -r4.18.0-60.el8.x86_64[user@host ~]$uname -aLinux host.lab.example.com 4.18.0-60.el8.x86_64 #1 SMP Fri Jan 11 19:08:11 UTC 2019 x86_64 x86_64 x86_64 GNU/Linuxyum remove
PACKAGENAMEremoves an installed software package, including any supported packages.[user@host ~]$sudo yum remove httpdWarning
The yum remove command removes the packages listed and any package that requires the packages being removed (and packages which require those packages, and so on). This can lead to unexpected removal of packages, so carefully review 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 8, there are two kinds of groups. Regular groups are collections of packages. Environment groups are collections of regular groups. The packages or groups provided by a group may be
mandatory(they must be installed if the group is installed),default(normally installed if the group is installed), oroptional(not installed when the group is installed, unless specifically requested).Like yum list, the yum group list command shows the names of installed and available groups.
[user@host ~]$yum group listAvailable Environment Groups: Server with GUI Minimal Install Server ...output omitted... Available Groups: Container Management .NET Core Development RPM Development Tools ...output omitted...Some groups are normally installed through environment groups and are hidden by default. List these hidden groups with the yum group list hidden command.
yum group info displays information about a group. It includes a list of mandatory, default, and optional package names.
[user@host ~]$yum group info "RPM Development Tools"Group: RPM Development Tools Description: These tools include core development tools such rpmbuild. Mandatory Packages: redhat-rpm-config rpm-build Default Packages: rpmdevtools Optional Packages: rpmlintyum group install installs a group that installs its mandatory and default packages and the packages they depend on.
[user@host ~]$sudo yum group install "RPM Development Tools"...output omitted... Installing Groups: RPM Development Tools Transaction Summary =============================================================================== Install 64 Packages Total download size: 21 M Installed size: 62 M Is this ok [y/N]: y ...output omitted...
Important
The behavior of Yum groups changed starting in Red Hat Enterprise Linux 7. In RHEL 7 and later, 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 are installed upon 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, or if any default or optional packages in the group are installed.
Starting in RHEL 7, a group is considered to be installed only if yum group install was used to install it.
The command yum group mark install GROUPNAME can be used to mark a group as installed, and any missing packages and their dependencies are installed upon 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 and RHEL 8 command yum group list did not.
Viewing transaction history
All install and remove transactions are logged in
/var/log/dnf.rpm.log.[user@host ~]$tail -5 /var/log/dnf.rpm.log2019-02-26T18:27:00Z SUBDEBUG Installed: rpm-build-4.14.2-9.el8.x86_64 2019-02-26T18:27:01Z SUBDEBUG Installed: rpm-build-4.14.2-9.el8.x86_64 2019-02-26T18:27:01Z SUBDEBUG Installed: rpmdevtools-8.10-7.el8.noarch 2019-02-26T18:27:01Z SUBDEBUG Installed: rpmdevtools-8.10-7.el8.noarch 2019-02-26T18:38:40Z INFO --- logging initialized ---yum history displays a summary of install and remove transactions.
[user@host ~]$sudo yum historyID | Command line | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 7 | group install RPM Develo | 2019-02-26 13:26 | Install | 65 6 | update kernel | 2019-02-26 11:41 | Install | 4 5 | install httpd | 2019-02-25 14:31 | Install | 9 4 | -y install @base firewal | 2019-02-04 11:27 | Install | 127 EE 3 | -C -y remove firewalld - | 2019-01-16 13:12 | Removed | 11 EE 2 | -C -y remove linux-firmw | 2019-01-16 13:12 | Removed | 1 1 | | 2019-01-16 13:05 | Install | 447 EEThe history undo option reverses a transaction.
[user@host ~]$sudo yum history undoUndoing transaction 7, from Tue 26 Feb 2019 10:40:32 AM EST Install apr-1.6.3-8.el8.x86_64 @rhel8-appstream Install apr-util-1.6.1-6.el8.x86_64 @rhel8-appstream Install apr-util-bdb-1.6.1-6.el8.x86_64 @rhel8-appstream Install apr-util-openssl-1.6.1-6.el8.x86_64 @rhel8-appstream Install httpd-2.4.37-7.module+el8+2443+605475b7.x86_64 @rhel8-appstream ...output omitted...5
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 name | yum list [NAME-PATTERN] |
| List installed and available groups | yum group list |
| Search for a package by keyword | yum search KEYWORD |
| Show details of a package | yum info PACKAGENAME |
| Install a package | yum install PACKAGENAME |
| Install a package group | yum group install GROUPNAME |
| Update all packages | yum update |
| Remove a package | yum remove PACKAGENAME |
| Display transaction history | yum history |
References
yum(1) and yum.conf(5) man pages
For more information, refer to the Managing software packages chapter in the Red Hat Enterprise Linux 8 Configuring basic system settings Guide at https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_basic_system_settings/index#managing-software-packages_configuring-basic-system-settings