2021 Call for Code Awards: Live from New York, with SNL’s Colin Jost! Learn more

Learn Linux, 101: RPM and YUM package management


In this tutorial, learn to use the RPM and YUM tools to manage the packages on your Linux system. Learn to:

  • Install, reinstall, upgrade, and remove packages using RPM and YUM.
  • Obtain information about RPM packages including version, status, dependencies, integrity, and signatures.
  • Determine what files a package provides, as well as find which package a specific file comes from.

This tutorial helps you prepare for Objective 102.5 in Topic 102 of the Linux Professional Institute’s Junior Level Administration (LPIC-1) exam 101. The objective has a weight of 3.

Introducing package management

In the past, many Linux programs were distributed as source code, which a user would build into the required program or set of programs, along with the required man pages, configuration files, and so on. Nowadays, most Linux distributors use prebuilt programs or sets of programs called packages, which ship ready for installation on that distribution. In this tutorial, you will learn about package management tools that help you install, update, and remove packages. This tutorial focuses on the Red Hat Package Manager (RPM), which was developed by Red Hat, as well as the Yellowdog Updater Modified (YUM), which was originally developed to manage Red Hat Linux systems at Duke University’s Physics department. Another tutorial in this series, “Learn Linux 101: Debian package management,” covers the package management tools used on Debian systems.

From a user perspective, the basic package management function is provided by commands. As Linux developers have striven to make Linux easier to use, the basic tools have been supplemented by other tools, including GUI tools, which hide some of the complexities of the basic tools from the end user. In this tutorial and in the tutorial on Debian package management, we focus on the basic tools, although we mention some of the other tools so you can pursue them further.


To get the most from the tutorials in this series, you should have a basic knowledge of Linux and a working Linux system on which you can practice the commands covered in this tutorial. Sometimes different versions of a program will format output differently, so your results may not always look exactly like the listings and figures shown here. In particular, much of the output we show is highly dependent on the packages that are already installed on our systems. Your own output may be quite different, although you should be able to recognize the important commonalities. The examples in this tutorial use a Fedora 20 system unless otherwise noted.

Package managers

RPM, YUM, and APT (for Debian systems) have many similarities. All can install and remove packages. Information about installed packages is kept in a database. All have basic command-line functionality, while additional tools can provide more user-friendly interfaces. All can retrieve packages from the Internet.

When you install a Linux system, you typically install a large selection of packages. The set may be customized to the intended use of the system, such as a server, desktop, or developer workstation. And at some time you will probably need to install new packages for added functionality, update the packages you have, or even remove packages that you no longer need or that have been made obsolete by newer packages. Let’s look at how you do these tasks, and at some of the related challenges such as finding which package might contain a particular command.


Red Hat introduced RPM in 1995. RPM is now the package management system used for packaging in the Linux Standard Base (LSB). The rpm command options are grouped into three subgroups for:

  • Querying and verifying packages
  • Installing, upgrading, and removing packages
  • Performing miscellaneous functions

We will focus on the first two sets of command options in this tutorial. You will find information about the miscellaneous functions in the man pages for RPM.

We should also note that rpm is the command name for the main command used with RPM, while .rpm is the extension used for RPM files. So “an rpm” or “the xxx rpm” will generally refer to an RPM file, while rpm will usually refer to the command.


YUM adds automatic updates and package management, including dependency management, to RPM systems. In addition to understanding the installed packages on a system, YUM is like the Debian Advanced Packaging Tool (APT) in that it works with repositories, which are collections of packages and are typically accessible over a network connection.

Installing RPM packages

Suppose you want to compile a Fortran program and a colleague tells you to use gfortran command. You might try gfortran –helpgfortran--help, or you might try which gfortranwhichgfortran, or type gfortrantypegfortran. But if your system can’t find gfortran, you might see output similar to that shown in Listing 1.

Listing 1. Missing gfortran command

[ian@attic‑f21 ~]$ gfortran ‑‑help
bash: gfortran: command not found

[ian@attic‑f21 ~]$ gfortran ‑‑help
bash: gfortran: command not found...
Install package 'gcc‑gfortran' to provide command 'gfortran'? [N/y] n

[ian@attic‑f21 ~]$ which gfortran
/usr/bin/which: no gfortran in (/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:

[ian@attic‑f21 ~]$ type gfortran
bash: type: gfortran: not found

If you did not get the helpful suggestion from the second form of output in Listing 1, you might check back with your colleague to find out which package to install. Otherwise, you might just guess that the gfortran command is in the gfortran package. This is often a good guess, but not always the right one and not the right one in this case. We’ll see later how to find the right package. Assuming that you know it’s really in the gcc-gfortran package and that you downloaded or otherwise acquired a copy of the package, you might try installing it using the rpm command with the -i (for install) option, as shown in Listing 2.

Listing 2. Installing gcc-gfortran with rpm – take 1

root@attic‑f21 ~rpm ‑i  gcc‑gfortran‑4.9.2‑6.fc21.x86_64.rpm 
error: Failed dependencies:
    libquadmath‑devel = 4.9.2‑6.fc21 is needed by gcc‑gfortran‑4.9.2‑6.fc21.x86_64

The rpm command knows that the package has a dependency, but unfortunately, it won’t help you resolve that dependency. You will need to get the dependent package or packages, try again, and see if there are additional dependencies—and keep doing this until all dependencies are satisfied. One good thing is that you can give the rpm command a list of packages to install and it will install them all in the right order if all dependencies are satisfied. So you at least don’t have to manually install each piece in the right order.

If you’ve used Debian’s APT, by this time you’re probably wishing you had something like the apt-get command, which would simply go and find what you need, including dependencies, and just install it. For RPM-based systems, YUM (or Yellowdog Updater Modified) provides just such a function. Listing 3 shows how to install gcc-gfortran and the required prerequisites using the yum command with the install option. Note: Your dependencies may differ according to what you already have installed on your system.

Listing 3. Installing gcc-gfortran using yum

root@attic‑f21 ~yum install gcc‑gfortran
Loaded plugins: langpacks
Resolving Dependencies
‑‑> Running transaction check
‑‑‑> Package gcc‑gfortran.x86_64 0:4.9.2‑6.fc21 will be installed
‑‑> Processing Dependency: libquadmath‑devel = 4.9.2‑6.fc21 for package: gcc‑gfortran‑4.9.2‑6.fc21.x86_64
‑‑> Running transaction check
‑‑‑> Package libquadmath‑devel.x86_64 0:4.9.2‑6.fc21 will be installed
‑‑> Finished Dependency Resolution

Dependencies Resolved

 Package                 Arch         Version               Repository     Size
 gcc‑gfortran            x86_64       4.9.2‑6.fc21          updates       7.7 M
Installing for dependencies:
 libquadmath‑devel       x86_64       4.9.2‑6.fc21          updates        37 k

Transaction Summary
Install  1 Package (+1 Dependent package)

Total download size: 7.7 M
Installed size: 18 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): libquadmath‑devel‑4.9.2‑6.fc21.x86_64.rpm            |  37 kB  00:00     
(2/2): gcc‑gfortran‑4.9.2‑6.fc21.x86_64.rpm                 | 7.7 MB  00:04     
Total                                              1.6 MB/s | 7.7 MB  00:04     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : libquadmath‑devel‑4.9.2‑6.fc21.x86_64                        1/2 
  Installing : gcc‑gfortran‑4.9.2‑6.fc21.x86_64                             2/2 
  Verifying  : libquadmath‑devel‑4.9.2‑6.fc21.x86_64                        1/2 
  Verifying  : gcc‑gfortran‑4.9.2‑6.fc21.x86_64                             2/2 

  gcc‑gfortran.x86_64 0:4.9.2‑6.fc21                                            

Dependency Installed:
  libquadmath‑devel.x86_64 0:4.9.2‑6.fc21                                       


The output in Listing 3 shows that YUM has found the x86_64 versions of gcc-gfortran and libquadmath-devel in a repository called “updates” (more on that shortly), and determined the total download size. After you respond “y” to agree to the transaction, it downloaded both packages, and then installed the dependency, followed by gcc-gfortran. You will learn more about dependencies later in this tutorial.

Note: In Listing 3, YUM found the latest version of the gcc-gfortran package which happened to be the same level (4.9.2-6) as the one we attempted to install in Listing 2. You will usually want the latest version of a package, but you can provide additional qualifications if you need an earlier version, or the i686 version instead of the x86_64 version. See the section on specifying package names in the man pages for the yum command.

Package locations

In the previous section, you learned how to install an RPM package. But where do the packages come from? How does yum know where to download packages from? The starting point is the /etc/yum.repos.d/ directory, which usually contains several repo files. This is the default location for repository information, but other locations may be specified in the YUM configuration file, normally /etc/yum.conf. Listing 4 shows the fedora-updates.repo corresponding to the location from which we installed gcc-gfortran on our Fedora 21 system.

A typical repo file is divided into three sections, one for normal packages, one for debug packages, and the last for source packages. Usually, there will be several copies of a distribution’s packages available from different locations, or mirrors. So the repo file tells yum where to find the latest list of mirrors for each section. Note that the distribution release level and machine architecture are parametrized, so yum would download the list for my x86_64 Fedora 21 system from https://mirrors.fedoraproject.org/metalink?repo=updates-released-f21&arch=x86_64.

In addition to the repository location, the repo file tells whether a particular repository is enabled and whether GPG signatures should be used to check the downloaded packages.

Listing 4. /etc/yum.repos.d/*.repo

[ian@attic‑f21 ~]$ cat /etc/yum.repos.d/fedora‑updates.repo
updatesname=Fedora $releasever ‑ $basearch ‑ Updates

name=Fedora $releasever ‑ $basearch ‑ Updates ‑ Debug

name=Fedora $releasever ‑ Updates Source

YUM and RPM use a local database to determine what packages are installed. The metadata about packages that is stored in the local database is retrieved from the enabled repositories. Although you will seldom need to worry about the local database, you use the command yum cleanyumclean to clean out various parts of the locally stored information and yum makecacheyummakecache to create the information in your local database for the enabled repos. You might do this if you change your repo configuration, for example.

Removing RPM packages

If you want to remove a package, you can use the remove option of yum, or the -e option of rpm. A test run to remove gcc-gfortran using rpm -erpm-e is shown in Listing 5. If the package can be removed, there is no output.

Listing 5. Test removal of gcc-gfortran

root@attic‑f21 ~rpm ‑e ‑‑test gcc‑gfortran

Unlike the simulated removal of Debian packages using apt-get, the RPM system does not maintain information on packages that were automatically added, so there is no trivial way to find out which dependencies might also be removed. However, if you specify multiple packages for removal on a single command, then packages without dependencies will be removed before packages that have dependencies.

When you remove packages using rpm, there is no prompt before the packages are removed, unlike when you install packages. However, if you attempt to remove a package that is required for some other package, the operation is not performed and you get an error message as shown in Listing 6.

Listing 6. Removing a dependent package with rpm

root@attic‑f21 ~rpm ‑e libquadmath‑devel
error: Failed dependencies:
    libquadmath‑devel = 4.9.2‑6.fc21 is needed by (installed) gcc‑gfortran‑4.9.2‑6.fc21.x86_64

If you use yum removeyumremove instead, then you will be prompted after the transaction tests are performed. If the package you are trying to remove is a dependent package for some other installed packages, then YUM will offer to remove those as well as the dependent package, as shown in Listing 7.

Listing 7. Removing a dependent package with yum

root@attic‑f21 ~yum remove libquadmath‑devel
Loaded plugins: langpacks
Resolving Dependencies
‑‑> Running transaction check
‑‑‑> Package libquadmath‑devel.x86_64 0:4.9.2‑6.fc21 will be erased
‑‑> Processing Dependency: libquadmath‑devel = 4.9.2‑6.fc21 for package: gcc‑gfortran‑4.9.2‑6.fc21.x86_64
‑‑> Running transaction check
‑‑‑> Package gcc‑gfortran.x86_64 0:4.9.2‑6.fc21 will be erased
‑‑> Finished Dependency Resolution

Dependencies Resolved

 Package                 Arch         Version              Repository      Size
 libquadmath‑devel       x86_64       4.9.2‑6.fc21         @updates        18 k
Removing for dependencies:
 gcc‑gfortran            x86_64       4.9.2‑6.fc21         @updates        18 M

Transaction Summary
Remove  1 Package (+1 Dependent package)

Installed size: 18 M
Is this ok [y/N]: n
Exiting on user command
Your transaction was saved, rerun it with:
 yum load‑transaction /tmp/yum_save_tx.2015‑07‑27.22‑01.amzaZh.yumtx

Upgrading RPM packages

Now that you know how to install and remove an RPM, let’s look at upgrading RPM packages to a newer level. You can use yum updateyumupdate to update your entire system, or you can specify a single package or a wildcard specification. Listing 8 shows how to update all the packages whose names start with “pop”. Note the use of apostrophes to prevent shell expansion of the “*”.

Listing 8. Updating using yum update

root@attic‑f21 ~yum update 'pop*'
Loaded plugins: langpacks
Resolving Dependencies
‑‑> Running transaction check
‑‑‑> Package poppler.x86_64 0:0.26.2‑3.fc21 will be updated
‑‑‑> Package poppler.x86_64 0:0.26.2‑9.fc21 will be an update
‑‑‑> Package poppler‑data.noarch 0:0.4.7‑1.fc21 will be updated
‑‑‑> Package poppler‑data.noarch 0:0.4.7‑2.fc21 will be an update
‑‑‑> Package poppler‑glib.x86_64 0:0.26.2‑3.fc21 will be updated
‑‑‑> Package poppler‑glib.x86_64 0:0.26.2‑9.fc21 will be an update
‑‑‑> Package poppler‑utils.x86_64 0:0.26.2‑3.fc21 will be updated
‑‑‑> Package poppler‑utils.x86_64 0:0.26.2‑9.fc21 will be an update
‑‑> Finished Dependency Resolution

Dependencies Resolved

 Package             Arch         Version             Repository     Size
 poppler             x86_64       0.26.2‑9.fc21       updates       798 k
 poppler‑data        noarch       0.4.7‑2.fc21        updates       2.2 M
 poppler‑glib        x86_64       0.26.2‑9.fc21       updates       141 k
 poppler‑utils       x86_64       0.26.2‑9.fc21       updates       171 k

Transaction Summary
Upgrade  4 Packages

Total download size: 3.2 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs reduced 3.1 M of updates to 315 k (89% saved)
(1/4): poppler‑data‑0.4.7‑1.fc21_0.4.7‑2.fc21.noarch. |  70 kB  00:00     
(2/4): poppler‑0.26.2‑3.fc21_0.26.2‑9.fc21.x86_64.drp | 208 kB  00:00     
(3/4): poppler‑glib‑0.26.2‑3.fc21_0.26.2‑9.fc21.x86_6 |  36 kB  00:00     
(4/4): poppler‑utils‑0.26.2‑9.fc21.x86_64.rpm         | 171 kB  00:00     
Finishing delta rebuilds of 3 package(s) (3.1 M)
Total                                        142 kB/s | 486 kB  00:03     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Updating   : poppler‑data‑0.4.7‑2.fc21.noarch                       1/8 
  Updating   : poppler‑0.26.2‑9.fc21.x86_64                           2/8 
  Updating   : poppler‑glib‑0.26.2‑9.fc21.x86_64                      3/8 
  Updating   : poppler‑utils‑0.26.2‑9.fc21.x86_64                     4/8 
  Cleanup    : poppler‑utils‑0.26.2‑3.fc21.x86_64                     5/8 
  Cleanup    : poppler‑glib‑0.26.2‑3.fc21.x86_64                      6/8 
  Cleanup    : poppler‑0.26.2‑3.fc21.x86_64                           7/8 
  Cleanup    : poppler‑data‑0.4.7‑1.fc21.noarch                       8/8 
  Verifying  : poppler‑data‑0.4.7‑2.fc21.noarch                       1/8 
  Verifying  : poppler‑glib‑0.26.2‑9.fc21.x86_64                      2/8 
  Verifying  : poppler‑0.26.2‑9.fc21.x86_64                           3/8 
  Verifying  : poppler‑utils‑0.26.2‑9.fc21.x86_64                     4/8 
  Verifying  : poppler‑data‑0.4.7‑1.fc21.noarch                       5/8 
  Verifying  : poppler‑utils‑0.26.2‑3.fc21.x86_64                     6/8 
  Verifying  : poppler‑glib‑0.26.2‑3.fc21.x86_64                      7/8 
  Verifying  : poppler‑0.26.2‑3.fc21.x86_64                           8/8 

  poppler.x86_64 0:0.26.2‑9.fc21                                          
  poppler‑data.noarch 0:0.4.7‑2.fc21                                      
  poppler‑glib.x86_64 0:0.26.2‑9.fc21                                     
  poppler‑utils.x86_64 0:0.26.2‑9.fc21                                    


If you know where the RPM files are located, or have downloaded them, you can also update them by using the rpm command. This is similar to installing, except that you use the -U or the -F option instead of the -i option. The difference between these two options is that the -U option will upgrade an existing package or install the package if it is not already installed, while the -F option will only upgrade or freshen a package that is already installed. Because of this, the -U option is frequently used, particularly when the command line contains a list of RPMs. This way, uninstalled packages are installed, while installed packages are upgraded. Two other options, -v (verbose) and -h (hash marks), are often used to give progress indication. Listing 9 shows how to update the cairo package and its cairo-gobject dependency using the rpm command. We have the cairo rpm already downloaded in root’s home directory, while we retrieve the cairo-gobject package from one of the update mirrors.

Listing 9. Updating packages with rpm

root@attic‑f21 ~ls .rpm
root@attic‑f21 ~rpm ‑Uvh .rpm 
> http://download.fedoraproject.org/pub/fedora/linux/updates/21/\
> x86_64/c/cairo‑gobject‑1.14.2‑1.fc21.x86_64.rpm
Retrieving http://download.fedoraproject.org/pub/fedora/linux/updates/21/x86_64/c/cairo‑g
Preparing...                          #################################100%Updating / installing...
   1:cairo‑1.14.2‑1.fc21              ################################# 25%   2:cairo‑gobject‑1.14.2‑1.fc21      ################################# 50%Cleaning up / removing...
   3:cairo‑gobject‑1.13.1‑0.4.git337ab################################# 75%   4:cairo‑1.13.1‑0.4.git337ab1f.fc21 #################################100%

Querying RPM packages

In our examples you saw that installing an rpm with the rpm command requires the full name of the package file (or URL), such as gcc-gfortran-4.9.2-6.fc21.x8664.rpm. On the other hand, installing with yum, or removing an rpm with either command requires only the package name, such as gcc-gfortran. As with APT, RPM maintains an internal database of your installed packages, allowing you to manipulate installed packages using the package name. In this section, we look at some of the information that is available to you from this database using the -q (for _query) option of the rpm command, or the associated yum queries.

We’ll reinstall the gcc-gfortran package to provide our examples.

The basic query simply asks if a package is installed, and, if so, what version. Add the -i option and you get information about the package. Note that you need to have root authority to install, upgrade, or remove packages, but non-root users can perform queries against the rpm database.

Listing 10. Displaying information about gcc-gfortran

[ian@attic‑f21 ~]$ yum list gcc‑gfortran
Loaded plugins: langpacks
Installed Packages
gcc‑gfortran.x86_64                    4.9.2‑6.fc21                     @updates
Available Packages
gcc‑gfortran.i686                      4.9.2‑6.fc21                     updates 

[ian@attic‑f21 ~]$ rpm ‑q gcc‑gfortran

[ian@attic‑f21 ~]$ yum info gcc‑gfortran
Loaded plugins: langpacks
Installed Packages
Name        : gcc‑gfortran
Arch        : x86_64
Version     : 4.9.2
Release     : 6.fc21
Size        : 18 M
Repo        : installed
From repo   : updates
Summary     : Fortran support
URL         : http://gcc.gnu.org
License     : GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and
            : LGPLv2+ and BSD
Description : The gcc‑gfortran package provides support for compiling Fortran
            : programs with the GNU Compiler Collection.

Available Packages
Name        : gcc‑gfortran
Arch        : i686
Version     : 4.9.2
Release     : 6.fc21
Size        : 7.5 M
Repo        : updates/21/x86_64
Summary     : Fortran support
URL         : http://gcc.gnu.org
License     : GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and
            : LGPLv2+ and BSD
Description : The gcc‑gfortran package provides support for compiling Fortran
            : programs with the GNU Compiler Collection.

[ian@attic‑f21 ~]$ rpm ‑qi gcc‑gfortran
Name        : gcc‑gfortran
Version     : 4.9.2
Release     : 6.fc21
Architecture: x86_64
Install Date: Mon 27 Jul 2015 09:36:14 PM EDT
Group       : Development/Languages
Size        : 19126083
License     : GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
Signature   : RSA/SHA256, Fri 13 Feb 2015 09:02:15 PM EST, Key ID 89ad4e8795a43f54
Source RPM  : gcc‑4.9.2‑6.fc21.src.rpm
Build Date  : Thu 12 Feb 2015 07:40:58 AM EST
Build Host  : buildhw‑08.phx2.fedoraproject.org
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://gcc.gnu.org
Summary     : Fortran support
Description :
The gcc‑gfortran package provides support for compiling Fortran
programs with the GNU Compiler Collection.

The more extensive listings show you some of the tags that can be associated with an RPM package. You will notice that rpm and yum show slightly different information in slightly different formats. For this tutorial, we will stick to the basic output provided by standard command options. See the man page if you would like to use the rpm –queryformatrpm--queryformat option to build custom query output. Try running rpm –querytagsrpm--querytags if you want to know all the tags supported by your version of rpm.

As shown in Listing 10, yum will list installed and available packages. We have the x86_64 (64-bit) version installed, but there is also an i686 (32-bit) version available. You can also use it to list packages that have updates available and packages with other characteristics, such as obsolete or recently added to a repository. You can even use yum to search for packages. In Listing 11, you see that the texmacs package is not installed, but is available from the fedora repository. If you search for “texmacs” you see four packages that mention it. You can easily see why the TeXmacs* packages were found. Use yum info pydotyuminfopydot to find out why the pydot package is also mentioned.

Listing 11. Displaying information about texmacs

[ian@attic‑f21 ~]$ yum list texmacs
Loaded plugins: langpacks
Available Packages
TeXmacs.x86_64            ‑4.fc20                       fedora
[ian@attic‑f21 ~]$ yum search texmacs
Loaded plugins: langpacks
============================= N/S matched: texmacs =============================
TeXmacs‑devel.i686 : Development files for TeXmacs
TeXmacs‑devel.x86_64 : Development files for TeXmacs
sympy‑texmacs.noarch : TeXmacs integration for sympy
texmacs‑fedora‑fonts.noarch : Fonts for TeXmacs
TeXmacs.x86_64 : Structured WYSIWYG scientific text editor

  Name and summary matches only, use "search all" for everything.

For the remaining query examples, we will mostly use rpm, as it has a more extensive set of options. Many of the examples can also be done with yum, and yum has some capabilities that are not in the basic rpm options. See the man pages to learn more.

RPM packages and files in them

You will often want to know what is in a package or what package a particular file came from. To list the files in the gcc-gfortran package, use the -ql option as shown in Listing 12. There are many files in this package, so we’ve only shown part of the output.

Listing 12. Displaying files in the gcc-gfortran package

[ian@attic‑f21 ~]$ rpm ‑ql gcc‑gfortran

You can restrict the files listed to just configuration files by adding the -c option to your query. Similarly, the -d option limits the display to just documentation files.

Querying package files

The above package commands query the RPM database for installed packages. If you just downloaded a package and want the same kind of information, you can get this using the -p option (for package file) on your query along with specifying the package file name (as used for installing the package). Listing 13 shows this for the two vim packages that we downloaded earlier. We run it as root only because the files were in root’s home directory. You can add other query options, such as -l to list files or -i to list information.

Listing 13. Displaying package file information for two vim packages

[ian@attic‑f21 ~]$ #Query vim packages
[ian@attic‑f21 ~]$ rpm ‑qp .rpm
[ian@attic‑f21 ~]$ #Query vim configuration files
[ian@attic‑f21 ~]$ rpm ‑qpc .rpm

Querying all installed packages

The -a option applies your query to all installed packages. This can generate a lot of output, so you will usually use it in conjunction with one or more filters, such as sort to sort the listing, more or less to page through it, wc to obtain package or file counts, or grep to search for packages if you aren’t sure of the name. Listing 14 shows the following queries:

  1. A sorted list of all packages on the system
  2. A count of all packages on the system
  3. A count of all files in all packages on the system
  4. A count of all documentation files installed with RPMs
  5. A search for all packages with “fortran” (case-insensitive) as part of their name

Listing 14. Queries against all packages

[ian@attic‑f21 ~]$ rpm ‑qa | sort | more
[[ian@attic‑f21 ~]$ rpm ‑qa | wc ‑l
[ian@attic‑f21 ~]$ rpm ‑qal | wc ‑l
[ian@attic‑f21 ~]$ rpm ‑qad | wc ‑l
[ian@attic‑f21 ~]$ rpm ‑qa | grep ‑i fortran

Using rpm -qa can ease the administration of multiple systems. If you redirect the sorted output to a file on one machine, and then do the same on the other machine, you can use the diff program to find differences.

Which package owns a file?

Given that you can list all packages and all files in a package, you now have all the information you need to find which package owns a file. However, the rpm command provides a -f (or --file) option to help you locate the package that owns an installed file. Suppose you want to know which of the vim packages we saw earlier actually provides the vim command. You will need to provide the full path to the file. Listing 15 shows how to use the which command to get the full path to the vim command, and a handy tip for using this output as input to the rpm -qf command. Note that the tick marks surrounding which vim are back-ticks. Another way of using this in the Bash shell is to use $(which vim).

Listing 15. Which package supplies the vim executable

[ian@attic‑f21 ~]$ which vim
[ian@attic‑f21 ~]$ rpm ‑qf which vim
[ian@attic‑f21 ~]$ rpm ‑qf $(which vim)

RPM dependencies

You saw earlier that our attempt to erase the libquadmath-devel failed because of dependencies. In addition to files, an RPM package may contain arbitrary capabilities that other packages may depend on.

As you have seen, this usually works out fine. If you need to install several packages at once, some of which may depend on others, simply use yum, or give the whole list to your rpm -Uvh command, and it will analyze the dependencies and perform the installs in the right order.

Besides trying to install or erase a package and getting an error message, there are ways to find out what files or capabilities a package requires or depends on.

The rpm command provides an option to interrogate installed packages or package files to find out what capabilities they depend on or require.This is the --requires option, which may be abbreviated to -R. Listing 16 shows the capabilities required by gcc-gfortran. Add the -p option and use the full RPM file name if you want to query the package file instead of the RPM database.

Listing 16. What does gcc-gfortran require

[ian@attic‑f21 ~]$ rpm ‑qR gcc‑gfortran
gcc = 4.9.2‑6.fc21
libgfortran = 4.9.2‑6.fc21
libquadmath = 4.9.2‑6.fc21
libquadmath‑devel = 4.9.2‑6.fc21
rpmlib(CompressedFileNames) <= 3.0.4‑1
rpmlib(FileDigests) <= 4.6.0‑1
rpmlib(PayloadFilesHavePrefix) <= 4.0‑1
rpmlib(PayloadIsXz) <= 5.2‑1

It can be somewhat tricky to match capabilities to the packages that provide them. The yum command with the deplist option can help here. If you just give a package name that is not qualified by version, you may get a listing for other known versions. Listing 17 shows how to get the dependency list for just the version of gcc-gfortran that is installed.

Listing 17. Using yum deplist to find what gcc-gfortran requires

[ian@attic‑f21 ~]$ rpm ‑q gcc‑gfortran
[ian@attic‑f21 ~]$ yum deplist $(rpm ‑q gcc‑gfortran)
Loaded plugins: langpacks
package: gcc‑gfortran.x86_64 4.9.2‑6.fc21
  dependency: /bin/sh
   provider: bash.x86_64 4.3.39‑1.fc21
  dependency: /sbin/install‑info
   provider: info.x86_64 5.2‑5.fc21
  dependency: gcc = 4.9.2‑6.fc21
   provider: gcc.x86_64 4.9.2‑6.fc21
  dependency: ld‑linux‑x86‑64.so.2()(64bit)
   provider: glibc.x86_64 2.20‑8.fc21
  dependency: ld‑linux‑x86‑64.so.2(GLIBC_2.3)(64bit)
   provider: glibc.x86_64 2.20‑8.fc21
  dependency: libc.so.6(GLIBC_2.4)(64bit)
   provider: glibc.x86_64 2.20‑8.fc21
  dependency: libdl.so.2()(64bit)
   provider: glibc.x86_64 2.20‑8.fc21
  dependency: libdl.so.2(GLIBC_2.2.5)(64bit)
   provider: glibc.x86_64 2.20‑8.fc21
  dependency: libgfortran = 4.9.2‑6.fc21
   provider: libgfortran.x86_64 4.9.2‑6.fc21
   provider: libgfortran.i686 4.9.2‑6.fc21
  dependency: libgfortran.so.3()(64bit)
   provider: libgfortran.x86_64 4.9.2‑6.fc21
  dependency: libgmp.so.10()(64bit)
   provider: gmp.x86_64 1:6.0.0‑9.fc21
  dependency: libm.so.6()(64bit)
   provider: glibc.x86_64 2.20‑8.fc21
  dependency: libmpc.so.3()(64bit)
   provider: libmpc.x86_64 1.0.2‑3.fc21
  dependency: libmpfr.so.4()(64bit)
   provider: mpfr.x86_64 3.1.2‑8.fc21
  dependency: libquadmath = 4.9.2‑6.fc21
   provider: libquadmath.x86_64 4.9.2‑6.fc21
   provider: libquadmath.i686 4.9.2‑6.fc21
  dependency: libquadmath‑devel = 4.9.2‑6.fc21
   provider: libquadmath‑devel.x86_64 4.9.2‑6.fc21
   provider: libquadmath‑devel.i686 4.9.2‑6.fc21
  dependency: libz.so.1()(64bit)
   provider: zlib.x86_64 1.2.8‑7.fc21
  dependency: rtld(GNU_HASH)
   provider: glibc.x86_64 2.20‑8.fc21
   provider: glibc.i686 2.20‑8.fc21

This list also shows possible providers for each capability. You can see that most dependencies could be provided by more than one alternative level of a package. For example, libquadmath could come from either the 32-bit or 64-bit version of the libquadmath package. With a little creative filtering, you can reduce this output to a list of package names as shown in Listing 18.

Listing 18. Reducing the yum deplist output to just list package names

[ian@attic‑f21 ~]$ yum deplist $(rpm ‑q gcc‑gfortran) | awk '/provider:/ { print $2 }'|sort|uniq

If you just need to know what packages need to be installed, you can always run yum installyuminstall and see the list before you are prompted to accept the installation proposal.

In addition to finding out what capabilities a package requires, you may need to find what package provides some capability. You saw above how to find which package owns a file. Listing 19 shows how to use rpm or yum to find what package provides the ld-linux-x86-64.so.2(GLIBC_2.3)(64bit) capability. In addition to information about installed packages providing the capability, YUM also shows the packages or versions available in repositories. These are the original 2.20-5 version from the fedora repository and the updated 2.20-8 version available from the updates repository.

Listing 19. What packages provide ld-linux-x86-64.so.2(GLIBC_2.3)(64bit) capability

[ian@attic‑f21 ~]$ rpm ‑q ‑‑whatprovides
[ian@attic‑f21 ~]$ yum whatprovides 'ld‑linux‑x86‑64.so.2(GLIBC_2.3)(64bit)'
Loaded plugins: langpacks
glibc‑2.20‑5.fc21.x86_64 : The GNU libc libraries
Repo        : fedora
Matched from:
Provides    : ld‑linux‑x86‑64.so.2(GLIBC_2.3)(64bit)

glibc‑2.20‑8.fc21.x86_64 : The GNU libc libraries
Repo        : updates
Matched from:
Provides    : ld‑linux‑x86‑64.so.2(GLIBC_2.3)(64bit)

glibc‑2.20‑8.fc21.x86_64 : The GNU libc libraries
Repo        : @updates
Matched from:
Provides    : ld‑linux‑x86‑64.so.2(GLIBC_2.3)(64bit)

RPM package file integrity

To ensure their integrity, RPM packages include a digest, such as MD5 or SHA1, and are usually digitally signed. Packages that are digitally signed need a public key for verification. To check the integrity of an RPM package file, use the --checksig (abbreviated to -K) option of rpm. You will usually find it useful to add the -v option for more verbose output. Listing 20 shows an example for the vim-enhanced RPM.

Listing 20. Checking the integrity of the vim-enhanced package file

[ian@attic‑f21 ~]$ rpm ‑vK vim‑enhanced‑7.4.475‑2.fc21.x86_64.rpm
    Header V3 RSA/SHA256 Signature, key ID 95a43f54: OK
    Header SHA1 digest: OK (696e492a4ee7a672cb3851d220de804dce0c9484)
    V3 RSA/SHA256 Signature, key ID 95a43f54: OK
    MD5 digest: OK (6bc225b37f43e7e7075668d04a73b9ea)

You may get an output line like that shown in , This means that you have a signed package, but you do not have the needed public key in your RPM database. Different versions of RPM may present the verification differently.

Listing 21.

[ian@attic‑f21 ~]$ rpm ‑K audacity‑freeworld‑2.1.1‑1.fc21.x86_64.rpm 
audacity‑freeworld‑2.1.1‑1.fc21.x86_64.rpm: RSA sha1 ((MD5) PGP) md5 NOT OK (MISSING KEYS: 
(MD5) PGP#6446d859) 
[ian@attic‑f21 ~]$ rpm ‑vK audacity‑freeworld‑2.1.1‑1.fc21.x86_64.rpm 
    Header V3 RSA/SHA256 Signature, key ID 6446d859: NOKEY
    Header SHA1 digest: OK (231ac5339a8084ba84a4a25d2a996f5d52434935)
    V3 RSA/SHA256 Signature, key ID 6446d859: NOKEY
    MD5 digest: OK (188d9cc3bfa2ac9b87483e387c8e74b6)

In this case, I downloaded the audacity package from the rpmfusion repository, but I have not installed that repository or its keys on my system.

If a package is signed and you want to verify it against a signature, then you will need to locate the appropriate signature file and import it into your RPM database. You should first download the key and then check its fingerprint before importing it using the rpm --import command. For more information, see the RPM man pages. You will also find more information on signed binaries at the RPM home page.

Verifying an installed package

Like checking the integrity of an rpm, you can also check the integrity of your installed files using rpm -V. This step makes sure that the files haven’t been modified since they were installed from the rpm. As shown in Listing 21, there is no output from this command if the package is still good, but you can add the -v option to get much more detailed output.

Listing 21. Verifying the installed vim-common package

[ian@attic‑f21 ~]$ rpm ‑V vim‑common

Let’s become root and corrupt our vim-common installation by deleting /usr/bin/xxd and replacing /usr/share/vim/vim74/syntax/bindzone.vim with /bin/bash. Let’s try the verification again. The results are shown in Listing 22.

Listing 22. Tampering with the vim-common package

root@attic‑f21 ~rpm ‑qf /usr/bin/xxd /usr/share/vim/vim74/syntax/bindzone.vim
root@attic‑f21 ~rm /usr/bin/xxd
rm: remove regular file ‘/usr/bin/xxd’? y
root@attic‑f21 ~cp /bin/bash /usr/share/vim/vim74/syntax/bindzone.vim
cp: overwrite ‘/usr/share/vim/vim74/syntax/bindzone.vim’? y
root@attic‑f21 ~rpm ‑V vim‑common
missing     /usr/bin/xxd
S.5....T.    /usr/share/vim/vim74/syntax/bindzone.vim

This output shows us that the /usr/share/vim/vim74/syntax/bindzone.vim file fails MD5 sum, file size, and mtime tests. One way to solve the problem would be to remove the package and then reinstall it, but there are other packages that depend on vim-common and that are installed and still OK. The solution is to forcibly reinstall it using the --force option of rpm, or the reinstall function of yum. Listing 23 shows how to reinstall with yum, and then verify that the package is now okay and the deleted file has been restored.

Listing 23. Reinstalling the vim-common package

root@attic‑f21 ~yum reinstall vim‑common
Loaded plugins: langpacks
Resolving Dependencies
‑‑> Running transaction check
‑‑‑> Package vim‑common.x86_64 2:7.4.475‑2.fc21 will be reinstalled
‑‑> Finished Dependency Resolution

Dependencies Resolved

 Package           Arch          Version                    Repository     Size
 vim‑common        x86_64        2:7.4.475‑2.fc21           fedora        5.9 M

Transaction Summary
Reinstall  1 Package

Total download size: 5.9 M
Installed size: 21 M
Is this ok [y/d/N]: y
Downloading packages:
vim‑common‑7.4.475‑2.fc21.x86_64.rpm                        | 5.9 MB  00:03     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : 2:vim‑common‑7.4.475‑2.fc21.x86_64                           1/1 
  Verifying  : 2:vim‑common‑7.4.475‑2.fc21.x86_64                           1/1 

  vim‑common.x86_64 2:7.4.475‑2.fc21                                            

root@attic‑f21 ~rpm ‑V vim‑common
root@attic‑f21 ~ls /usr/bin/xxd

If you need more force

Usually the package management system keeps your packages in order. However, if you manage to delete some file that is an important part of a package—and reinstalling the package without removing does not fix the problem—then you may need to remove the package before reinstalling. For such a case, you probably want to delete the existing copy and reinstall it, without needing to uninstall and reinstall all the packages that depend on it. For this, you can use the rpm command’s --nodeps option to bypass dependency checking when you remove a package. Listing 24 shows how this might work if you accidentally removed the /usr/bin/xxd file, which is part of the vim-common package, as we did earlier.

Listing 24. Updating packages with rpm

root@attic‑f21 ~rm /usr/bin/xxd
rm: remove regular file ‘/usr/bin/xxd’? y
root@attic‑f21 ~#Oops! we needed that file
root@attic‑f21 ~rpm ‑Fvh vim‑common‑7.4.475‑2.fc21.x86_64.rpm 
root@attic‑f21 ~ls /usr/bin/xxd
ls: cannot access /usr/bin/xxd: No such file or directory
root@attic‑f21 ~#Oh! Freshening the package didn't replace the missing file
root@attic‑f21 ~rpm ‑e vim‑common
error: Failed dependencies:
    vim‑common = 2:7.4.475‑2.fc21 is needed by (installed) vim‑enhanced‑2:7.4.475‑2.fc21.x86_64
root@attic‑f21 ~#Can't remove vim‑common because vim‑enhanced needs it
root@attic‑f21 ~rpm ‑e ‑‑nodeps vim‑common
warning: file /usr/bin/xxd: remove failed: No such file or directory
root@attic‑f21 ~#Bypassing the dependency check allowed removal
root@attic‑f21 ~#No surprise that /usr/bin/xxd was not found
root@attic‑f21 ~#Update (or install) vim‑common again
root@attic‑f21 ~rpm ‑Uvh vim‑common‑7.4.475‑2.fc21.x86_64.rpm
Preparing...                          #################################100%Updating / installing...
   1:vim‑common‑2:7.4.475‑2.fc21      #################################100%root@attic‑f21 ~ls /usr/bin/xxd
root@attic‑f21 ~#And /usr/bin/xxd is back

So now you have some approaches to updating or repairing if accidents happen and the ordinary update process fails. Note that you can also bypass dependency checking when installing an RPM, but this not usually a good idea.

Downloading RPMs from repositories

Although yum will automatically retrieve packages from repositories, you may want to download RPMs and save them, perhaps to install them on a non-networked system, or to examine their contents, or for some other reason. You can use the yumdownloader command to do this as shown in Listing 25. In our case, the gcc-gfortran.x86_64 package is already installed, so there are no additional packages to download.

Listing 25. Downloading the gcc-gfortran package

[ian@attic‑f21 ~]$ yumdownloader ‑‑resolve gcc‑gfortran.x86_64
Loaded plugins: langpacks
‑‑> Running transaction check
‑‑‑> Package gcc‑gfortran.x86_64 0:4.9.2‑6.fc21 will be reinstalled
‑‑> Finished Dependency Resolution
gcc‑gfortran‑4.9.2‑6.fc21.x86_64.rpm                       | 7.7 MB  00:04     

The --resolve option of yumdownloader will cause other required packages to be downloaded, too. To illustrate this I 686-download also shows the files downloaded using the --resolve option when we download gcc-gfortran. Note that we did not specify an architecture (x86_64 or i686), so the default download is for the i686 version.

Downloading the gcc-gfortran package

[ian@attic‑f21 ~]$ yumdownloader ‑‑resolve gcc‑gfortran
Loaded plugins: langpacks
updates/21/x86_64/metalink                                 |  14 kB  00:00     
‑‑> Running transaction check
‑‑‑> Package gcc‑gfortran.i686 0:4.9.2‑6.fc21 will be installed
‑‑> Processing Dependency: libz.so.1(ZLIB_1.2.3.3) for package: gcc‑gfortran‑4.9.2‑6.fc21.i686
‑‑> Processing Dependency: libz.so.1 for package: gcc‑gfortran‑4.9.2‑6.fc21.i686
‑‑> Processing Dependency: libmpfr.so.4 for package: gcc‑gfortran‑4.9.2‑6.fc21.i686
‑‑> Processing Dependency: libmpc.so.3 for package: gcc‑gfortran‑4.9.2‑6.fc21.i686
‑‑> Processing Dependency: libm.so.6 for package: gcc‑gfortran‑4.9.2‑6.fc21.i686
‑‑> Processing Dependency: libgmp.so.10 for package: gcc‑gfortran‑4.9.2‑6.fc21.i686
‑‑> Processing Dependency: libgfortran.so.3 for package: gcc‑gfortran‑4.9.2‑6.fc21.i686
‑‑> Processing Dependency: libdl.so.2(GLIBC_2.1) for package: gcc‑gfortran‑4.9.2‑6.fc21.i686
‑‑> Processing Dependency: libdl.so.2(GLIBC_2.0) for package: gcc‑gfortran‑4.9.2‑6.fc21.i686
‑‑> Processing Dependency: libdl.so.2 for package: gcc‑gfortran‑4.9.2‑6.fc21.i686
‑‑> Processing Dependency: libc.so.6(GLIBC_2.4) for package: gcc‑gfortran‑4.9.2‑6.fc21.i686
‑‑> Processing Dependency: ld‑linux.so.2(GLIBC_2.3) for package: gcc‑gfortran‑4.9.2‑6.fc21.i686
‑‑> Processing Dependency: ld‑linux.so.2 for package: gcc‑gfortran‑4.9.2‑6.fc21.i686
‑‑‑> Package gcc‑gfortran.x86_64 0:4.9.2‑6.fc21 will be reinstalled
‑‑> Running transaction check
‑‑‑> Package glibc.i686 0:2.20‑8.fc21 will be installed
‑‑> Processing Dependency: libfreebl3.so(NSSRAWHASH_3.12.3) for package: glibc‑2.20‑8.fc21.i686
‑‑> Processing Dependency: libfreebl3.so for package: glibc‑2.20‑8.fc21.i686
‑‑‑> Package gmp.i686 1:6.0.0‑9.fc21 will be installed
‑‑> Processing Dependency: libstdc++.so.6(GLIBCXX_3.4.11) for package: 1:gmp‑6.0.0‑9.fc21.i686
‑‑> Processing Dependency: libstdc++.so.6(GLIBCXX_3.4) for package: 1:gmp‑6.0.0‑9.fc21.i686
‑‑> Processing Dependency: libstdc++.so.6(CXXABI_1.3) for package: 1:gmp‑6.0.0‑9.fc21.i686
‑‑> Processing Dependency: libstdc++.so.6 for package: 1:gmp‑6.0.0‑9.fc21.i686
‑‑> Processing Dependency: libgcc_s.so.1(GCC_3.0) for package: 1:gmp‑6.0.0‑9.fc21.i686
‑‑> Processing Dependency: libgcc_s.so.1 for package: 1:gmp‑6.0.0‑9.fc21.i686
‑‑‑> Package libgfortran.i686 0:4.9.2‑6.fc21 will be installed
‑‑> Processing Dependency: libquadmath.so.0(QUADMATH_1.0) for package: libgfortran‑4.9.2‑6.fc21.i686
‑‑> Processing Dependency: libquadmath.so.0 for package: libgfortran‑4.9.2‑6.fc21.i686
‑‑‑> Package libmpc.i686 0:1.0.2‑3.fc21 will be installed
‑‑‑> Package mpfr.i686 0:3.1.2‑8.fc21 will be installed
‑‑‑> Package zlib.i686 0:1.2.8‑7.fc21 will be installed
‑‑> Running transaction check
‑‑‑> Package libgcc.i686 0:4.9.2‑6.fc21 will be installed
‑‑‑> Package libquadmath.i686 0:4.9.2‑6.fc21 will be installed
‑‑‑> Package libstdc++.i686 0:4.9.2‑6.fc21 will be installed
‑‑‑> Package nss‑softokn‑freebl.i686 0:3.19.2‑1.0.fc21 will be installed
‑‑> Finished Dependency Resolution
(1/12): gcc‑gfortran‑4.9.2‑6.fc21.i686.rpm                 | 7.5 MB  00:04     
(2/12): glibc‑2.20‑8.fc21.i686.rpm                         | 4.1 MB  00:02     
(3/12): gmp‑6.0.0‑9.fc21.i686.rpm                          | 420 kB  00:01     
(4/12): libgcc‑4.9.2‑6.fc21.i686.rpm                       |  97 kB  00:00     
(5/12): libgfortran‑4.9.2‑6.fc21.i686.rpm                  | 270 kB  00:00     
(6/12): gcc‑gfortran‑4.9.2‑6.fc21.x86_64.rpm               | 7.7 MB  00:09     
(7/12): libmpc‑1.0.2‑3.fc21.i686.rpm                       |  56 kB  00:01     
(8/12): libquadmath‑4.9.2‑6.fc21.i686.rpm                  | 243 kB  00:00     
(9/12): mpfr‑3.1.2‑8.fc21.i686.rpm                         | 211 kB  00:00     
(10/12): libstdc++‑4.9.2‑6.fc21.i686.rpm                   | 314 kB  00:00     
(11/12): nss‑softokn‑freebl‑3.19.2‑1.0.fc21.i686.rpm       | 195 kB  00:00     
(12/12): zlib‑1.2.8‑7.fc21.i686.rpm                        |  97 kB  00:00     

Compare the list of downloaded packages to the 64-bit entries in list we built in Listing 18.

Using rpm2cpio

If you download an RPM and need to examine its contents, rather than install it, you can use the rpm2cpiocommand to convert the contents to a cpio archive and then filter that through the cpio command to extract individual files or all the files in the package. Listing 26 shows how to do this for the gcc-gfortran package and then shows some of the files (and directories) that were unpacked. See the man pages for rpm2cpio and cpio for additional details on these commands.

Listing 26. Unpacking the gcc-gfortran package with rpm2cpio

[[ian@attic‑f21 ~]$ mkdir gcc‑gfortran
[ian@attic‑f21 ~]$ cd gcc‑gfortran
[ian@attic‑f21 gcc‑gfortran]$ rpm2cpio ../gcc‑gfortran‑4.9.2‑6.fc21.x86_64.rpm | cpio ‑idv
37373 blocks
[ian@attic‑f21 gcc‑gfortran]$ find . | head

Finding RPMs

We saw earlier that YUM offers a search capability, which searches descriptions as well as package names. If you need to find what package contains a program that you do not have installed, there are a few other ways:

  • You can guess what package might contain it and download the package without installing. Once you have the package, you can interrogate it.
  • You can search the Internet.
  • You may be able to use the command-not-found capability described below.

If you can’t find a particular RPM through your system tools, a good Internet resource for locating RPMs is the Rpmfind.Net server.

Command not found

When the Bash shell searches for a command and does not find it, then the shell searches for a shell function named command_not_found_handle. If the command_not_found_handle function exists, it is invoked with the original command and original arguments as its arguments, and the function’s exit status becomes the exit status of the shell. If the function is not defined, the shell prints an error message and returns an exit status of 127. The function is usually set in the system /etc/bash.bashrc file or another profile file such as /etc/profile.d/PackageKit.sh. Listing 27 shows how we searched for the command-not-found capability. If it is not already installed on your system, you now know how to install it.

Listing 27. Locating and installing the command-not-found capability

[ian@attic‑f21 ~]$ yum search command‑not‑found
Loaded plugins: langpacks
======================= N/S matched: command‑not‑found ========================
PackageKit‑command‑not‑found.x86_64 : Ask the user to install command line
                                    : programs automatically

  Name and summary matches only, use "search all" for everything.

Listing 28 shows how the function handle is defined after installing PackageKit-command-not-found. If the function cannot perform the search, then it mimics the standard system behavior and returns 127.

Listing 28. The command_not_found_handle

[ian@attic‑f21 ~]$ type command_not_found_handle
command_not_found_handle is a function
command_not_found_handle () 
    local runcnf=1;
    local retval=127;
    [[ $‑ =~ i ]] || runcnf=0;
    [ ! ‑S /var/run/dbus/system_bus_socket ] && runcnf=0;
    [ ! ‑x /usr/libexec/packagekitd ] && runcnf=0;
    if [ $runcnf ‑eq 1 ]; then
        /usr/libexec/pk‑command‑not‑found "$@";
        echo "bash: $1: command not found";
    return $retval

At the beginning of this tutorial, we showed you two different outputs from gfortran –helpgfortran--help. The first showed you a response with command_not_found_handle disabled and the second was with it enabled. Go back and review Listing 1 to see the difference.

Other tools

In addition to yum and rpm, your distributor may provide other tools for installing packages from the repository or updating your entire system. These tools may be graphical or command line or both. Some examples include:

  • YaST (SUSE)
  • up2date (Red Hat)
  • Mandrake Software Management (Mandriva)

Usually these tools will handle multiple package updates in an automatic or semi-automatic fashion. They may also provide capabilities to display contents of repositories or search for packages. Consult the documentation for your distribution for more details.


With Fedora 22, Red Hat replaced the venerable yum with a new tool called dnf (for dandified yum). It has been in Fedora packages since Fedora 18 as a tech preview. According to the project page:

The reason of initiating DNF project was because of the biggest three pitfalls of Yum: undocumented API, broken dependency solving algorithm and inability to refactor internal functions. The last mentioned issue is connected with the lack of documentation.

Most of the command line interface is similar or identical to yum and the tools are also similar or have equivalents. Using yum commands on system that uses dnf will usually work, albeit with a warning that the yum command is deprecated and you should use dnf.

While dnf is not yet part of the LPI objectives, you should be aware of it as a replacement for yum.


No discussion of package installation would be complete without mentioning PackageKit, which is a system designed to make installing and updating software easier. The intent is to unify all the software graphical tools used in different distributions. PackageKit uses a system activated daemon, which means that the daemon is activated only when needed. PackageKit has version for Gnome (gnome-packagekit) and KDE KPackageKit). The command-not-found handle described above is also part of PackageKit. It includes the commands pkcon to perform package management functions from the console, and pkmon to monitor package kit activity. It also includes graphical tools for adding software packages, or for updating your system. shows an example of the Gnome PackageKit (/usr/bin/gpk-application) graphical interface.

Figure 1. Gnome PackageKit graphical interface on Fedora 21
Screen shot of the Software Update graphical interface on Fedora 21 (Gnome)

At the time of writing, recent Fedora releases have replaced PackageKit with a new Software package, called gnome-software. The project claims:

The new tool, named gnome-software, is designed from the beginning for installing applications. It will present applications with information that is relevant to users (icons, screenshots, reviews, descriptions, ratings,…) instead of information that is relevant for packagers (dependencies, package size, file lists,…).

This does not work with all packages, only checks for updates on a specific schedule, and requires unnecessary reboots. See Bug 1064717 for an explanation of why this is as designed. You can install the gnome-packagekit-installer and gnome-packagekit-updater packages to get PackageKit functionality.

There is a lot more to the RPM and YUM package management systems than covered here.