yum/dnf Package Manager Basics

yum install bash-doc yum install bash-doc

Every modern Linux distribution comes with a set of tools for installing and updating software. Such tools are called package managers.

Package managers help you find software, download it to your computer and install or upgrade it. When a certain software package can’t work without additional components, relevant software packages will be installed automatically.

In Red Hat family of operating systems the package manager is called yum. In recent years it’s been replaced with backward-compatible tool called dnf.

yum package manager

yum stands for Yet Another package Manager.

When running the yum command you should specify a sub command followed by optional package or file names.

IMPORTANT: Many functions of the package manager can be used by regular users, but installing and removing software requires root privilege.

List installed software packages

Here’s how you can list all the installed packages on your system (warning! it will be a long list)

$ yum list installed
Last metadata expiration check: 0:03:17 ago on Mon 01 Mar 2021 10:50:35 GMT.
Installed Packages
NetworkManager.x86_64                                  1:1.26.0-8.el8                                    @anaconda
NetworkManager-libnm.x86_64                            1:1.26.0-8.el8                                    @anaconda
NetworkManager-team.x86_64                             1:1.26.0-8.el8                                    @anaconda
NetworkManager-tui.x86_64                              1:1.26.0-8.el8                                    @anaconda
PackageKit.x86_64                                      1.1.12-6.el8                                      @centos-updates
PackageKit-glib.x86_64                                 1.1.12-6.el8                                      @centos-updates
abattis-cantarell-fonts.noarch                         0.0.25-4.el8                                      @centos-updates
acl.x86_64                                             2.2.53-1.el8                                      @anaconda
adcli.x86_64                                           0.8.2-7.el8                                       @anaconda
at.x86_64                                              3.1.20-11.el8                                     @anaconda
attr.x86_64                                            2.4.48-3.el8                                      @anaconda
audit.x86_64                                           3.0-0.17.20191104git1c2f876.el8                   @anaconda
audit-libs.x86_64                                      3.0-0.17.20191104git1c2f876.el8                   @anaconda
authselect.x86_64                                      1.2.1-2.el8                                       @anaconda
authselect-compat.x86_64                               1.2.1-2.el8                                       @centos-updates
authselect-libs.x86_64                                 1.2.1-2.el8                                       @anaconda
avahi-libs.x86_64                                      0.7-19.el8                                        @anaconda
basesystem.noarch                                      11-5.el8                                          @anaconda
bash.x86_64                                            4.4.19-12.el8                                     @anaconda
...

It’s a lot more useful to filter this output using grep command.

Let’s get the list of all the Python related packages installed:

$ yum list installed | grep python
platform-python.x86_64                                 3.6.8-31.el8                                      @anaconda
platform-python-devel.x86_64                           3.6.8-31.el8                                      @appstream
platform-python-pip.noarch                             9.0.3-18.el8                                      @anaconda
platform-python-setuptools.noarch                      39.2.0-6.el8                                      @anaconda
policycoreutils-python-utils.noarch                    2.9-9.el8                                         @anaconda
python-josepy-doc.noarch                               1.2.0-5.el8                                       @epel
python-rpm-macros.noarch                               3-39.el8                                          @appstream
python-srpm-macros.noarch                              3-39.el8                                          @appstream
python2.x86_64                                         2.7.17-2.module_el8.3.0+478+7570e00c              @appstream
python2-libs.x86_64                                    2.7.17-2.module_el8.3.0+478+7570e00c              @appstream
python2-pip.noarch                                     9.0.3-18.module_el8.3.0+478+7570e00c              @appstream
python2-pip-wheel.noarch                               9.0.3-18.module_el8.3.0+478+7570e00c              @appstream
python2-setuptools.noarch                              39.0.1-12.module_el8.3.0+478+7570e00c             @appstream
python2-setuptools-wheel.noarch                        39.0.1-12.module_el8.3.0+478+7570e00c             @appstream
python3-acme.noarch                                    1.10.1-1.el8                                      @epel
python3-asn1crypto.noarch                              0.24.0-3.el8                                      @baseos
python3-audit.x86_64                                   3.0-0.17.20191104git1c2f876.el8                   @anaconda
python3-bind.noarch                                    32:9.11.20-5.el8                                  @centos-updates
python3-cairo.x86_64                                   1.16.3-6.el8                                      @centos-updates
python3-certbot.noarch                                 1.11.0-1.el8                                      @epel
python3-cffi.x86_64                                    1.11.5-5.el8                                      @baseos
python3-chardet.noarch                                 3.0.4-7.el8                                       @baseos
...

Search for software packages

yum lets you find new software, too. If you are a user of bash shell, you can easily find all the related autocompletion packages like this:

$ yum search bash
Last metadata expiration check: 0:06:11 ago on Mon 01 Mar 2021 10:50:35 GMT.
================================================================== Name Exactly Matched: bash ==================================================================
bash.x86_64 : The GNU Bourne Again shell
================================================================= Name & Summary Matched: bash =================================================================
argbash.noarch : Bash argument parsing code generator
bash-completion.noarch : Programmable completion for Bash
bash-doc.x86_64 : Documentation files for bash
bashmount.noarch : A menu-driven bash script for mounting removable media
coccinelle-bash-completion.noarch : Bash tab-completion for coccinelle
drbd-bash-completion.x86_64 : Programmable bash completion support for drbdadm
libguestfs-bash-completion.noarch : Bash tab-completion scripts for libguestfs tools
libvirt-bash-completion.x86_64 : Bash completion script
nbdkit-bash-completion.noarch : Bash tab-completion for nbdkit
pcp-pmda-bash.x86_64 : Performance Co-Pilot (PCP) metrics for the Bash shell
python-django-bash-completion.noarch : bash completion files for Django
python-django3-bash-completion.noarch : Bash completion files for Django
python3-colcon-bash.noarch : Extension for colcon to provide Bash scripts
votca-csg-bash.noarch : Bash completion for VOTCA CSG

yum search output shows you exact matches first - packages that fully match your search pattern. Later in the output you can see all the packages that have your pattern in the package name: bash-completion, bash-doc etc.

Install software with yum

Once you know a package name, just use the yum install command to have it downloaded and installed.

Software installation is a global change in your operating system, this means you will have to use sudo command when running yum install.

If you try running yum install as regular user, you’ll see an error:

$ yum install bash-doc
Error: This command has to be run with superuser privileges (under the root user on most systems).

Let’s use sudo and yum to install the bash-doc package:

$ sudo yum install bash-doc
Last metadata expiration check: 1:20:45 ago on Mon 01 Mar 2021 09:44:35 GMT.
Dependencies resolved.
================================================================================================================================================================
 Package                               Architecture                        Version                                    Repository                           Size
================================================================================================================================================================
Installing:
 bash-doc                              x86_64                              4.4.19-12.el8                              baseos                              1.2 M

Transaction Summary
================================================================================================================================================================
Install  1 Package

Total download size: 1.2 M
Installed size: 4.6 M
Is this ok [y/N]: y
Downloading Packages:
bash-doc-4.4.19-12.el8.x86_64.rpm                                                                                                27 MB/s | 1.2 MB     00:00
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                           5.2 MB/s | 1.2 MB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                        1/1
  Installing       : bash-doc-4.4.19-12.el8.x86_64                                                                                                          1/1
  Verifying        : bash-doc-4.4.19-12.el8.x86_64                                                                                                          1/1

Installed:
  bash-doc-4.4.19-12.el8.x86_64

Complete!

Congratulations! You now know how to install software with yum.

Uninstall Software with yum

Let’s learn the last basic function of using package manager in Red Hat: uninstalling software packages.

You’ll need sudo privilege and specify exact package name in order to uninstall it:

$ yum remove bash-doc
Error: This command has to be run with superuser privileges (under the root user on most systems).
[[email protected] ~]$ sudo yum remove bash-doc
Dependencies resolved.
================================================================================================================================================================
 Package                              Architecture                       Version                                      Repository                           Size
================================================================================================================================================================
Removing:
 bash-doc                             x86_64                             4.4.19-12.el8                                @baseos                             4.6 M

Transaction Summary
================================================================================================================================================================
Remove  1 Package

Freed space: 4.6 M
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                        1/1
  Erasing          : bash-doc-4.4.19-12.el8.x86_64                                                                                                          1/1
  Verifying        : bash-doc-4.4.19-12.el8.x86_64                                                                                                          1/1

Removed:
  bash-doc-4.4.19-12.el8.x86_64

Complete!

Well done! Basic knowledge of yum/dnf usage will let you quickly check, install or remove software as necessary.

See Also




Keep Learning with Me

Follow me on Facebook and Twitter or jump into Telegram chat!:
Recommended Software
I use Brave browser, it's awesome: Brave Browser I'm also a fan of SetApp for macOS: SetApp for macOS
IT Consultancy
I'm a principal consultant with Tech Stack Solutions. I help with cloud architectrure, AWS deployments and automated management of Unix/Linux infrastructure. Get in touch!

Recent Tweets