Red Hat Training

A Red Hat training course is available for RHEL 8

Chapter 7. Managing software packages

7.1. Software management tools in RHEL 8

In RHEL 8, software installation is enabled by the new version of the YUM tool (YUM v4), which is based on the DNF technology.

Note

Upstream documentation identifies the technology as DNF and the tool is referred to as DNF in the upstream. As a result, some output returned by the new YUM tool in RHEL 8 mentions DNF.

Although YUM v4 used in RHEL 8 is based on DNF, it is compatible with YUM v3 used in RHEL 7. For software installation, the yum command and most of its options work the same way in RHEL 8 as they did in RHEL 7.

Selected yum plug-ins and utilities have been ported to the new DNF back end, and can be installed under the same names as in RHEL 7. Packages also provide compatibility symlinks, so the binaries, configuration files, and directories can be found in usual locations.

Note that the legacy Python API provided by YUM v3 is no longer available. You can migrate your plug-ins and scripts to the new API provided by YUM v4 (DNF Python API), which is stable and fully supported. See DNF API Reference for more information.

7.2. Application streams

RHEL 8 introduces the concept of Application Streams. Multiple versions of user space components are now delivered and updated more frequently than the core operating system packages. This provides greater flexibility to customize Red Hat Enterprise Linux without impacting the underlying stability of the platform or specific deployments.

Components made available as Application Streams can be packaged as modules or RPM packages, and are delivered through the AppStream repository in RHEL 8. Each Application Stream has a given life cycle, either the same as RHEL 8 or shorter, more suitable to the particular application. Application Streams with a shorter life cycle are listed in the Red Hat Enterprise Linux 8 Application Streams Life Cycle page.

Modules are collections of packages representing a logical unit: an application, a language stack, a database, or a set of tools. These packages are built, tested, and released together.

Module streams represent versions of the Application Stream components. For example, two streams (versions) of the PostgreSQL database server are available in the postgresql module: PostgreSQL 10 (the default stream) and PostgreSQL 9.6. Only one module stream can be installed on the system. Different versions can be used in separate containers.

Detailed module commands are described in the Installing, managing, and removing user-space components document. For a list of modules available in AppStream, see the Package manifest.

7.3. Searching for software packages

yum allows you to perform a complete set of operations with software packages.

The following section describes how to use yum to:

  • Search for packages.
  • List packages.
  • List repositories.
  • Display information about the packages.
  • List package groups.
  • Specify global expressions in yum input.

7.3.1. Searching packages with YUM

Use the following procedure to find a package providing a particular application or other content.

Procedure

  • To search for a package, use:

    # yum search term

    Replace term with a term related to the package.

    Note that yum search command returns term matches within the name and summary of the packages. This makes the search faster and enables you to search for packages you do not know the name of, but for which you know a related term.

  • To include term matches within package descriptions, use:

    # yum search --all term

    Replace term with a term you want to search for in a package name, summary, or description.

    Note that yum search --all enables a more exhaustive but slower search.

7.3.2. Listing packages with YUM

Use the following procedure to list installed and available packages.

Procedure

  • To list information about all installed and available packages, use:

    # yum list --all
  • To list all packages installed on your system, use:

    # yum list --installed
  • To list all packages in all enabled repositories that are available to install, use:

    # yum list --available

Note that you can filter the results by appending global expressions as arguments. See Specifying global expressions in yum input

for more details.

7.3.3. Listing repositories with YUM

Use the following procedure to list enabled and disabled repositories.

Procedure

  • To list all enabled repositories on your system, use:

    # yum repolist
  • To list all disabled repositories on your system, use:

    # yum repolist --disabled
  • To list both enabled and disabled repositories, use:

    # yum repolist --all
  • To list additional information about the repositories, use:

    # yum repoinfo

Note that you can filter the results by passing the ID or name of repositories as arguments or by appending global expressions. See Specifying global expressions in yum input

for more details.

7.3.4. Displaying package information with YUM

You can display various types of information about a package using YUM, for example version, release, size, loaded plugins, and more.

Procedure

  • To display information about one or more packages, use:

    # yum info package-name

    Replace package-name with the name of the package.

Note that you can filter the results by appending global expressions as arguments. See Specifying global expressions in yum input

for more details.

7.3.5. Listing package groups with YUM

Use yum to view installed package groups and filter the listing results.

Procedure

  • To view the number of installed and available groups, use:

    # yum group summary
  • To list all installed and available groups, use:

    # yum group list

    Note that you can filter the results by appending command line options for the yum group list command (--hidden, --available). For more available options see the man pages.

  • To list mandatory and optional packages contained in a particular group, use:

    # yum group info group-name

    Replace group-name with the name of the group.

Note that you can filter the results by appending global expressions as arguments. See Specifying global expressions in yum input

for more details.

7.3.6. Specifying global expressions in YUM input

yum commands allow you to filter the results by appending one or more glob expressions as arguments. You have to escape global expressions when passing them as arguments to the yum command.

Procedure

To ensure global expressions are passed to yum as intended, use one of the following methods:

  • Double-quote or single-quote the entire global expression.

    # yum provides "*/file-name"

    Replace file-name with the name of the file.

  • Escape the wildcard characters by preceding them with a backslash (\) character.

    # yum provides \*/file-name

    Replace file-name with the name of the file.

7.4. Installing software packages

The following section describes how to use yum to:

  • Install packages.
  • Install a package group.
  • Specify a package name in yum input.

7.4.1. Installing packages with YUM

  • To install a package and all the package dependencies, use:

    # yum install package-name

    Replace package-name with the name of the package.

  • To install multiple packages and their dependencies simultaneously, use:

    # yum install package-name-1 package-name-2

    Replace package-name-1 and package-name-2 with the names of the packages.

  • When installing packages on a multilib system (AMD64, Intel 64 machine), you can specify the architecture of the package by appending it to the package name:

    # yum install package-name.arch

    Replace package-name.arch with the name and architecture of the package.

  • If you know the name of the binary you want to install, but not the package name, you can use the path to the binary as an argument:

    # yum install /usr/sbin/binary-file

    Replace /usr/sbin/binary-file with a path to the binary file.

    yum searches through the package lists, finds the package which provides /usr/sbin/binary-file, and prompts you as to whether you want to install it.

  • To install a previously-downloaded package from a local directory, use:

    # yum install /path/

    Replace /path/ with the path to the package.

Note that you can optimize the package search by explicitly defining how to parse the argument. See Section 7.4.3, “Specifying a package name in YUM input” for more details.

7.4.2. Installing a package group with YUM

The following procedure describes how to install a package group by a group name or by a groupID using yum.

Procedure

  • To install a package group by a group name, use:

    # yum group install group-name

    Or

    # yum install @group-name

    Replace group-name with the full name of the group or environmental group.

  • To install a package group by the groupID, use:

    # yum group install groupID

    Replace groupID with the ID of the group.

7.4.3. Specifying a package name in YUM input

To optimize the installation and removal process, you can append -n, -na, or -nevra suffixes to yum install and yum remove commands to explicitly define how to parse an argument:
  • To install a package using its exact name, use:

    # yum install-n name

    Replace name with the exact name of the package.

  • To install a package using its exact name and architecture, use:

    # yum install-na name.architecture

    Replace name and architecture with the exact name and architecture of the package.

  • To install a package using its exact name, epoch, version, release, and architecture, use:

    # yum install-nevra name-epoch:version-release.architecture

    Replace name, epoch, version, release, and architecture with the exact name, epoch, version, release, and architecture of the package.

7.5. Updating software packages

yum allows you to check if your system has any pending updates. You can list packages that need updating and choose to update a single package, multiple packages, or all packages at once. If any of the packages you choose to update have dependencies, they are updated as well.

The following section describes how to use yum to:

  • Check for updates.
  • Update a single package.
  • Update a package group.
  • Update all packages and their dependencies.
  • Apply security updates.
  • Automate software updates.

7.5.1. Checking for updates with YUM

The following procedure describes how to check the available updates for packages installed on your system using yum.

Procedure

  • To see which packages installed on your system have available updates, use:

    # yum check-update

    The output returns the list of packages and their dependencies that have an update available.

7.5.2. Updating a single package with YUM

Use the following procedure to update a single package and its dependencies using yum.

  • To update a package, use:

    # yum update package-name

    Replace package-name with the name of the package.

Important

When applying updates to kernel, yum always installs a new kernel regardless of whether you are using the yum update or yum install command.

7.5.3. Updating a package group with YUM

Use the following procedure to update a group of packages and their dependencies using yum.

Procedure

  • To update a package group, use:

    # yum group update group-name

    Replace group-name with the name of the package group.

7.5.4. Updating all packages and their dependencies with YUM

Use the following procedure to update all packages and their dependencies using yum.

Procedure

  • To update all packages and their dependencies, use:

    # yum update

7.5.6. Automating software updates

To check and download package updates automatically and regularly, you can use the DNF Automatic tool that is provided by the dnf-automatic package.

DNF Automatic is an alternative command-line interface to yum that is suited for automatic and regular execution using systemd timers, cron jobs and other such tools.

DNF Automatic synchronizes package metadata as needed and then checks for updates available. After, the tool can perform one of the following actions depending on how you configure it:

  • Exit
  • Download updated packages
  • Download and apply the updates

The outcome of the operation is then reported by a selected mechanism, such as the standard output or email.

7.5.6.1. Installing DNF Automatic

The following procedure describes how to install the DNF Automatic tool.

Procedure

  • To install the dnf-automatic package, use:

    # yum install dnf-automatic

Verification steps

  • To verify the successful installation, confirm the presence of the dnf-automatic package by running the following command:

    # rpm -qi dnf-automatic

7.5.6.2. DNF Automatic configuration file

By default, DNF Automatic uses /etc/dnf/automatic.conf as its configuration file to define its behavior.

The configuration file is separated into the following topical sections:

  • [commands] section

    Sets the mode of operation of DNF Automatic.

  • [emitters] section

    Defines how the results of DNF Automatic are reported.

  • [command_email] section

    Provides the email emitter configuration for an external command used to send email.

  • [email] section

    Provides the email emitter configuration.

  • [base] section

    Overrides settings from the main configuration file of yum.

With the default settings of the /etc/dnf/automatic.conf file, DNF Automatic checks for available updates, downloads them, and reports the results as standard output.

Warning

Settings of the operation mode from the [commands] section are overridden by settings used by a systemd timer unit for all timer units except dnf-automatic.timer.

Additional resources

7.5.6.3. Enabling DNF Automatic

To run DNF Automatic, you always need to enable and start a specific systemd timer unit. You can use one of the timer units provided in the dnf-automatic package, or you can write your own timer unit depending on your needs.

The following section describes how to enable DNF Automatic.

Prerequisites

  • You specified the behavior of DNF Automatic by modifying the /etc/dnf/automatic.conf configuration file.

For more information about DNF Automatic configuration file, see Section 2.5.6.2, “DNF Automatic configuration file”.

Procedure

  • Select, enable and start a systemd timer unit that fits your needs:

    # systemctl enable --now <unit>

where <unit> is one of the following timers:

  • dnf-automatic-download.timer
  • dnf-automatic-install.timer
  • dnf-automatic-notifyonly.timer
  • dnf-automatic.timer

    • To download available updates, use:

      # systemctl enable dnf-automatic-download.timer
      # systemctl start dnf-automatic-download.timer
    • To download and install available updates, use:

      # systemctl enable dnf-automatic-install.timer
      # systemctl start dnf-automatic-install.timer
    • To report about available updates, use:

      # systemctl enable dnf-automatic-notifyonly.timer
      # systemctl start dnf-automatic-notifyonly.timer
    • Optionally, you can use:

      # systemctl enable dnf-automatic.timer
      # systemctl start dnf-automatic.timer

In terms of downloading and applying updates, this timer unit behaves according to settings in the /etc/dnf/automatic.conf configuration file. The default behavior is similar to dnf-automatic-download.timer: it downloads the updated packages, but it does not install them.

Note

Alternatively, you can also run DNF Automatic by executing the /usr/bin/dnf-automatic file directly from the command line or from a custom script.

Verification steps

  • To verify that the timer is enabled, run the following command:

    # systemctl status <systemd timer unit>

Additional resources

7.5.6.4. Overview of the systemd timer units included in the dnf-automatic package

The systemd timer units take precedence and override the settings in the /etc/dnf/automatic.conf configuration file concerning downloading and applying updates.

For example if you set the following option in the /etc/dnf/automatic.conf configuration file, but you have activated the dnf-automatic-notifyonly.timer unit, the packages will not be downloaded:

download_updates = yes

The dnf-automatic package includes the following systemd timer units:

Timer unitFunctionOverrides settings in the /etc/dnf/automatic.conf file?

dnf-automatic-download.timer

Downloads packages to cache and makes them available for updating.

Note: This timer unit does not install the updated packages. To perform the installation, you have to execute the dnf update command.

Yes

dnf-automatic-install.timer

Downloads and installs updated packages.

Yes

dnf-automatic-notifyonly.timer

Downloads only repository data to keep repository cache up-to-date and notifies you about available updates.

Note: This timer unit does not download or install the updated packages

Yes

dnf-automatic.timer

The behavior of this timer concerning downloading and applying updates is specified by the settings in the /etc/dnf/automatic.conf configuration file.

Default behavior is the same as for the dnf-automatic-download.timer unit: it only downloads packages, but does not install them.

No

Additional resources

  • For more information about the dnf-automatic timers, see the man dnf-automatic manual pages.
  • For more information about the /etc/dnf/automatic.conf configuration file, see Section DNF Automatic configuration file

7.6. Uninstalling software packages

The following section describes how to use yum to:

  • Remove packages.
  • Remove a package group.
  • Specify a package name in yum input.

7.6.1. Removing packages with YUM

Use the following procedure to remove a package either by the group name or the groupID.

Procedure

  • To remove a particular package and all dependent packages, use:

    # yum remove package-name

    Replace package-name with the name of the package.

  • To remove multiple packages and their dependencies simultaneously, use:

    # yum remove package-name-1 package-name-2

    Replace package-name-1 and package-name-2 with the names of the packages.

Note

yum is not able to remove a package without removing depending packages.

Note that you can optimize the package search by explicitly defining how to parse the argument. See Specifying a package name in yum input for more details.

7.6.2. Removing a package group with YUM

Use the following procedure to remove a package either by the group name or the groupID.

Procedure

  • To remove a package group by the group name, use:

    # yum group remove group-name

    Or

    # yum remove @group-name

    Replace group-name with the full name of the group.

  • To remove a package group by the groupID, use:

    # yum group remove groupID

    Replace groupID with the ID of the group.

7.6.3. Specifying a package name in YUM input

To optimize the installation and removal process, you can append -n, -na, or -nevra suffixes to yum install and yum remove commands to explicitly define how to parse an argument:
  • To install a package using its exact name, use:

    # yum install-n name

    Replace name with the exact name of the package.

  • To install a package using its exact name and architecture, use:

    # yum install-na name.architecture

    Replace name and architecture with the exact name and architecture of the package.

  • To install a package using its exact name, epoch, version, release, and architecture, use:

    # yum install-nevra name-epoch:version-release.architecture

    Replace name, epoch, version, release, and architecture with the exact name, epoch, version, release, and architecture of the package.

7.7. Managing software package groups

A package group is a collection of packages that serve a common purpose (System Tools, Sound and Video). Installing a package group pulls a set of dependent packages, which saves time considerably.

The following section describes how to use yum to:

  • List package groups.
  • Install a package group.
  • Remove a package group.
  • Specify global expressions in yum input.

7.7.1. Listing package groups with YUM

Use yum to view installed package groups and filter the listing results.

Procedure

  • To view the number of installed and available groups, use:

    # yum group summary
  • To list all installed and available groups, use:

    # yum group list

    Note that you can filter the results by appending command line options for the yum group list command (--hidden, --available). For more available options see the man pages.

  • To list mandatory and optional packages contained in a particular group, use:

    # yum group info group-name

    Replace group-name with the name of the group.

Note that you can filter the results by appending global expressions as arguments. See Specifying global expressions in yum input

for more details.

7.7.2. Installing a package group with YUM

The following procedure describes how to install a package group by a group name or by a groupID using yum.

Procedure

  • To install a package group by a group name, use:

    # yum group install group-name

    Or

    # yum install @group-name

    Replace group-name with the full name of the group or environmental group.

  • To install a package group by the groupID, use:

    # yum group install groupID

    Replace groupID with the ID of the group.

7.7.3. Removing a package group with YUM

Use the following procedure to remove a package either by the group name or the groupID.

Procedure

  • To remove a package group by the group name, use:

    # yum group remove group-name

    Or

    # yum remove @group-name

    Replace group-name with the full name of the group.

  • To remove a package group by the groupID, use:

    # yum group remove groupID

    Replace groupID with the ID of the group.

7.7.4. Specifying global expressions in YUM input

yum commands allow you to filter the results by appending one or more glob expressions as arguments. You have to escape global expressions when passing them as arguments to the yum command.

Procedure

To ensure global expressions are passed to yum as intended, use one of the following methods:

  • Double-quote or single-quote the entire global expression.

    # yum provides "*/file-name"

    Replace file-name with the name of the file.

  • Escape the wildcard characters by preceding them with a backslash (\) character.

    # yum provides \*/file-name

    Replace file-name with the name of the file.

7.8. Handling package management history

The yum history command allows you to review information about the timeline of yum transactions, dates and times they occurred, the number of packages affected, whether these transactions succeeded or were aborted, and if the RPM database was changed between transactions. yum history command can also be used to undo or redo the transactions.

The following section describes how to use yum to:

  • List transactions.
  • Revert transactions.
  • Repeat transactions.
  • Specify global expressions in yum input.

7.8.1. Listing transactions with YUM

Use the following procedure to list the latest transactions, the latest operations for a selected package, and details of a particular transaction.

Procedure

  • To display a list of all the latest yum transactions, use:

    # yum history
  • To display a list of all the latest operations for a selected package, use:

    # yum history list package-name

    Replace package-name with the name of the package. You can filter the command output by appending global expressions. See Specifying global expressions in yum input for more details.

  • To examine a particular transaction, use:

    # yum history info transactionID

    Replace transactionID with the ID of the transaction.

7.8.2. Reverting transactions with YUM

The following procedure describes how to revert a selected transaction or the last transaction using yum.

Procedure

  • To revert a particular transaction, use:

    # yum history undo transactionID

    Replace transactionID with the ID of the transaction.

  • To revert the last transaction, use:

    # yum history undo last

Note that the yum history undo command only reverts the steps that were performed during the transaction. If the transaction installed a new package, the yum history undo command uninstalls it. If the transaction uninstalled a package, the yum history undo command reinstalls it. yum history undo also attempts to downgrade all updated packages to their previous versions, if the older packages are still available.

7.8.3. Repeating transactions with YUM

Use the following procedure to repeat a selected transaction or the last transaction using yum.

Procedure

  • To repeat a particular transaction, use:

    # yum history redo transactionID

    Replace transactionID with the ID of the transaction.

  • To repeat the last transaction, use:

    # yum history redo last

Note that the yum history redo command only repeats the steps that were performed during the transaction.

7.8.4. Specifying global expressions in YUM input

yum commands allow you to filter the results by appending one or more glob expressions as arguments. You have to escape global expressions when passing them as arguments to the yum command.

Procedure

To ensure global expressions are passed to yum as intended, use one of the following methods:

  • Double-quote or single-quote the entire global expression.

    # yum provides "*/file-name"

    Replace file-name with the name of the file.

  • Escape the wildcard characters by preceding them with a backslash (\) character.

    # yum provides \*/file-name

    Replace file-name with the name of the file.

7.9. Managing software repositories

The configuration information for yum and related utilities are stored in the /etc/yum.conf file. This file contains one or more [repository] sections, which allow you to set repository-specific options.

It is recommended to define individual repositories in new or existing .repo files in the /etc/yum.repos.d/ directory.

Note that the values you define in individual [repository] sections of the /etc/yum.conf file override values set in the [main] section.

The following section describes how to:

  • Set [repository] options.
  • Add a yum repository.
  • Enable a yum repository.
  • Disable a yum repository.

7.9.1. Setting YUM repository options

The /etc/yum.conf configuration file contains the [repository] sections, where repository is a unique repository ID. The [repository] sections allows you to define individual yum repositories.

Note

Do not give custom repositories names used by the Red Hat repositories to avoid conflicts.

For a complete list of available [repository] options, see the [repository] OPTIONS section of the yum.conf(5) manual page.

7.9.2. Adding a YUM repository

Procedure

To define a new repository, you can:

  • Add a [repository] section to the /etc/yum.conf file.
  • Add a [repository] section to a .repo file in the /etc/yum.repos.d/ directory.

    yum repositories commonly provide their own .repo file.

Note

It is recommended to define your repositories in a .repo file instead of /etc/yum.conf as all files with the .repo file extension in this directory are read by yum.

  • To add a repository to your system and enable it, use:

    # yum-config-manager --add-repo repository_URL

    Replace repository_url with URL pointing to the repository.

Warning

Obtaining and installing software packages from unverified or untrusted sources other than Red Hat certificate-based Content Delivery Network (CDN) constitutes a potential security risk, and could lead to security, stability, compatibility, and maintainability issues.

7.9.3. Enabling a YUM repository

Once you added a yum repository to your system, enable it to ensure installation and updates.

Procedure

  • To enable a repository, use:

    # yum-config-manager --enable repositoryID

    Replace repositoryID with the unique repository ID.

    To list available repository IDs, see Listing packages with yum.

7.9.4. Disabling a YUM repository

Disable a specific YUM repository to prevent particular packages from installation or update.

Procedure

  • To disable a yum repository, use:

    # yum-config-manager --disable repositoryID

    Replace repositoryID with the unique repository ID.

    To list available repository IDs, see Listing packages with yum.

7.10. Configuring YUM

The configuration information for yum and related utilities are stored in the /etc/yum.conf file. This file contains one mandatory [main] section, which enables you to set yum options that have global effect.

The following section describes how to:

  • View the current yum configurations.
  • Set yum [main] options.
  • Use yum plug-ins.

7.10.1. Viewing the current YUM configurations

Use the following procedure to view the current yum configurations.

Procedure

  • To display the current values of global yum options specified in the [main] section of the /etc/yum.conf file, use:

    # yum config-manager --dump

7.10.2. Setting YUM main options

The /etc/yum.conf configuration file contains one [main] section. The key-value pairs listed below affect how yum operates and treats repositories.

You can add additional options under the [main] section heading in /etc/yum.conf.

For a complete list of available [main] options, see the [main] OPTIONS section of the yum.conf(5) manual page.

7.10.3. Using YUM plug-ins

yum provides plug-ins that extend and enhance its operations. Certain plug-ins are installed by default.

The following section describes how to enable, configure, and disable yum plug-ins.

7.10.3.1. Managing YUM plug-ins

Procedure

The plug-in configuration files always contain a [main] section where the enabled= option controls whether the plug-in is enabled when you run yum commands. If this option is missing, you can add it manually to the file.

Every installed plug-in has its own configuration file in the /etc/dnf/plugins/ directory. You can enable or disable plug-in specific options in these files.

7.10.3.2. Enabling YUM plug-ins

The following procedure describes how to disable or enable all YUM plug-ins, disable all plug-ins for a particular command, or certain YUM plug-ins for a single command.

Procedure

  • To enable all yum plug-ins:

    1. Ensure a line beginning with plugins= is present in the [main] section of the /etc/yum.conf file.
    2. Set the value of plugins= to 1.

      plugins=1

7.10.3.3. Disabling YUM plug-ins

  • To disable all yum plug-ins:

    1. Ensure a line beginning with plugins= is present in the [main] section of the /etc/yum.conf file.
    2. Set the value of plugins= to 0.

      plugins=0
      Important

      Disabling all plug-ins is not advised. Certain plug-ins provide important yum services. In particular, the product-id and subscription-manager plug-ins provide support for the certificate-based Content Delivery Network (CDN). Disabling plug-ins globally is provided as a convenience option, and is advisable only when diagnosing a potential problem with yum.

  • To disable all yum plug-ins for a particular command, append --noplugins option to the command.

    # yum --noplugins update
  • To disable certain yum plug-ins for a single command, append --disableplugin=plugin-name option to the command.

    # yum update --disableplugin=plugin-name

    Replace plugin-name with the name of the plug-in.