Learn Linux, 101: RPM and YUM package management Add new software and keep your system current Ian Shields Linux Author Freelance 21 December 2015 (First published 11 May 2010) Learn how to install, upgrade and manage packages on your Linux® system. This tutorial focuses on the Red Hat Package Manager (RPM) developed by Red Hat, as well as the Yellowdog Updater Modified (YUM) originally developed to manage Red Hat Linux systems at Duke University's Physics department. You can use the material in this tutorial to study for the LPI 101 exam for Linux system administrator certification, or just to explore the best ways to add new software and keep your system current. View more content in this series Overview 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 © Copyright IBM Corporation 2010, 2015 Learn Linux, 101: RPM and YUM package management Trademarks Page 1 of 25 developerWorks® ibm.com/developerWorks/ 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. About this series This series of tutorials helps you learn Linux system administration tasks. You can also use the material in these tutorials to prepare for the Linux Professional Institute's LPIC-1: Linux Server Professional Certification exams. See "Learn Linux, 101: A roadmap for LPIC-1" for a description of and link to each tutorial in this series. The roadmap is in progress and reflects the version 4.0 objectives of the LPIC-1 exams as updated April 15th, 2015. As tutorials are completed, they will be added to the roadmap. 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. Prerequisites 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 commandline 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. Learn Linux, 101: RPM and YUM package management Page 2 of 25 ibm.com/developerWorks/ developerWorks® RPM 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 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 --help, or you might try which gfortran, or type gfortran. But if your system can't find gfortran, you might see output similar to that shown in . 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: /home/ian/.local/bin:/home/ian/bin) [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 , 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 . Learn Linux, 101: RPM and YUM package management Page 3 of 25 developerWorks® ibm.com/developerWorks/ 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 aptget 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. 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. 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 ================================================================================ Installing: 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 Learn Linux, 101: RPM and YUM package management Page 4 of 25 ibm.com/developerWorks/ Installing : gcc-gfortran-4.9.2-6.fc21.x86_64 Verifying : libquadmath-devel-4.9.2-6.fc21.x86_64 Verifying : gcc-gfortran-4.9.2-6.fc21.x86_64 developerWorks® 2/2 1/2 2/2 Installed: gcc-gfortran.x86_64 0:4.9.2-6.fc21 Dependency Installed: libquadmath-devel.x86_64 0:4.9.2-6.fc21 Complete! The output in shows that YUM has found the x86_64 versions of gcc-gfortran and libquadmathdevel 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 , 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 . 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. 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. /etc/yum.repos.d/*.repo [ian@attic-f21 ~]$ cat /etc/yum.repos.d/fedora-updates.repo [updates] name=Fedora $releasever - $basearch - Updates failovermethod=priority #baseurl=http://download.fedoraproject.org/pub/fedora/linux/updates/$releasever/$basearch/ metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-released-f$releasever&arch=$ basearch enabled=1 Learn Linux, 101: RPM and YUM package management Page 5 of 25 developerWorks® ibm.com/developerWorks/ metadata_expire=6h gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch skip_if_unavailable=False [updates-debuginfo] name=Fedora $releasever - $basearch - Updates - Debug failovermethod=priority #baseurl=http://download.fedoraproject.org/pub/fedora/linux/updates/$releasever/$basearch/debug/ metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-released-debug-f$releasever& arch=$basearch enabled=0 gpgcheck=1 metadata_expire=6h gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch skip_if_unavailable=False [updates-source] name=Fedora $releasever - Updates Source failovermethod=priority #baseurl=http://download.fedoraproject.org/pub/fedora/linux/updates/$releasever/SRPMS/ metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-released-source-f$releasever& arch=$basearch enabled=0 gpgcheck=1 metadata_expire=6h gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch skip_if_unavailable=False 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 clean to clean out various parts of the locally stored information and yum makecache 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 -e is shown in . If the package can be removed, there is no output. 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 . Learn Linux, 101: RPM and YUM package management Page 6 of 25 ibm.com/developerWorks/ developerWorks® 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 remove 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 . 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 ================================================================================ Removing: 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 update to update your entire system, or you can specify a single package or a wildcard specification. shows how to update all the packages whose names start with "pop". Note the use of apostrophes to prevent shell expansion of the "*". 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 Learn Linux, 101: RPM and YUM package management Page 7 of 25 developerWorks® ibm.com/developerWorks/ ---> 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 ========================================================================== Updating: 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 Updated: 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 Complete! 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 Learn Linux, 101: RPM and YUM package management Page 8 of 25 ibm.com/developerWorks/ developerWorks® packages are installed, while installed packages are upgraded. Two other options, -v (verbose) and -h (hash marks), are often used to give progress indication. 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. Updating packages with rpm [root@attic-f21 ~]# ls *.rpm cairo-1.14.2-1.fc21.x86_64.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 object-1.14.2-1.fc21.x86_64.rpm 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.x86_64.rpm. On the other hand, installing with yum, or removing an rpm with either command requires only the package name, such as gccgfortran. 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. 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 Available Packages gcc-gfortran.i686 4.9.2-6.fc21 @updates updates [ian@attic-f21 ~]$ rpm -q gcc-gfortran gcc-gfortran-4.9.2-6.fc21.x86_64 [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 Learn Linux, 101: RPM and YUM package management Page 9 of 25 developerWorks® Size Repo From repo Summary URL License : : : : : : : Description : : ibm.com/developerWorks/ 18 M installed updates Fortran support http://gcc.gnu.org GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD 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 --queryformat option to build custom query output. Try running rpm --querytags if you want to know all the tags supported by your version of rpm. As shown in , 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 , 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 pydot to find out why the pydot package is also mentioned. Learn Linux, 101: RPM and YUM package management Page 10 of 25 ibm.com/developerWorks/ developerWorks® Displaying information about texmacs [ian@attic-f21 ~]$ yum list texmacs Loaded plugins: langpacks Available Packages TeXmacs.x86_64 1.0.7.19-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 . There are many files in this package, so we've only shown part of the output. Displaying files in the gcc-gfortran package [ian@attic-f21 ~]$ rpm -ql gcc-gfortran /usr/bin/f95 /usr/bin/gfortran /usr/lib/gcc /usr/lib/gcc/x86_64-redhat-linux /usr/lib/gcc/x86_64-redhat-linux/4.9.2 /usr/lib/gcc/x86_64-redhat-linux/4.9.2/32 /usr/lib/gcc/x86_64-redhat-linux/4.9.2/32/libcaf_single.a /usr/lib/gcc/x86_64-redhat-linux/4.9.2/32/libgfortran.a /usr/lib/gcc/x86_64-redhat-linux/4.9.2/32/libgfortran.so /usr/lib/gcc/x86_64-redhat-linux/4.9.2/32/libgfortranbegin.a /usr/lib/gcc/x86_64-redhat-linux/4.9.2/finclude /usr/lib/gcc/x86_64-redhat-linux/4.9.2/finclude/omp_lib.f90 /usr/lib/gcc/x86_64-redhat-linux/4.9.2/finclude/omp_lib.h /usr/lib/gcc/x86_64-redhat-linux/4.9.2/finclude/omp_lib.mod /usr/lib/gcc/x86_64-redhat-linux/4.9.2/finclude/omp_lib_kinds.mod /usr/lib/gcc/x86_64-redhat-linux/4.9.2/libcaf_single.a /usr/lib/gcc/x86_64-redhat-linux/4.9.2/libgfortran.so /usr/lib/gcc/x86_64-redhat-linux/4.9.2/libgfortran.spec /usr/lib/gcc/x86_64-redhat-linux/4.9.2/libgfortranbegin.a /usr/libexec/gcc /usr/libexec/gcc/x86_64-redhat-linux /usr/libexec/gcc/x86_64-redhat-linux/4.9.2 /usr/libexec/gcc/x86_64-redhat-linux/4.9.2/f951 /usr/share/doc/gcc-gfortran /usr/share/doc/gcc-gfortran/ChangeLog-2002.bz2 /usr/share/doc/gcc-gfortran/ChangeLog-2002.libgfortran.bz2 ... usr/share/doc/gcc-gfortran/ChangeLog.bz2 /usr/share/doc/gcc-gfortran/ChangeLog.libgfortran.bz2 /usr/share/doc/gcc-gfortran/ChangeLog.ptr.bz2 /usr/share/info/gfortran.info.gz /usr/share/man/man1/gfortran.1.gz Learn Linux, 101: RPM and YUM package management Page 11 of 25 developerWorks® ibm.com/developerWorks/ 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). 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. Displaying package file information for two vim packages [ian@attic-f21 ~]$ # Query vim packages [ian@attic-f21 ~]$ rpm -qp *.rpm vim-common-7.4.475-2.fc21.x86_64 vim-enhanced-7.4.475-2.fc21.x86_64 [ian@attic-f21 ~]$ # Query vim configuration files [ian@attic-f21 ~]$ rpm -qpc *.rpm /etc/vimrc /etc/profile.d/vim.csh /etc/profile.d/vim.sh 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. 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 Queries against all packages [ian@attic-f21 ~]$ rpm -qa | sort | more aaajohan-comfortaa-fonts-2.004-4.fc21.noarch aalib-libs-1.4.0-0.26.rc5.fc21.x86_64 abattis-cantarell-fonts-0.0.16-2.fc21.noarch abrt-2.3.0-8.fc21.x86_64 abrt-addon-ccpp-2.3.0-8.fc21.x86_64 abrt-addon-kerneloops-2.3.0-8.fc21.x86_64 abrt-addon-pstoreoops-2.3.0-8.fc21.x86_64 abrt-addon-python-2.3.0-8.fc21.x86_64 abrt-addon-python3-2.3.0-8.fc21.x86_64 abrt-addon-vmcore-2.3.0-8.fc21.x86_64 abrt-addon-xorg-2.3.0-8.fc21.x86_64 abrt-cli-2.3.0-8.fc21.x86_64 abrt-dbus-2.3.0-8.fc21.x86_64 abrt-desktop-2.3.0-8.fc21.x86_64 abrt-gui-2.3.0-8.fc21.x86_64 abrt-gui-libs-2.3.0-8.fc21.x86_64 Learn Linux, 101: RPM and YUM package management Page 12 of 25 ibm.com/developerWorks/ developerWorks® abrt-java-connector-1.1.0-2.fc21.x86_64 abrt-libs-2.3.0-8.fc21.x86_64 abrt-plugin-bodhi-2.3.0-8.fc21.x86_64 abrt-python-2.3.0-8.fc21.x86_64 abrt-python3-2.3.0-8.fc21.x86_64 abrt-retrace-client-2.3.0-8.fc21.x86_64 abrt-tui-2.3.0-8.fc21.x86_64 --More-[[ian@attic-f21 ~]$ rpm -qa | wc -l 1540 [ian@attic-f21 ~]$ rpm -qal | wc -l 179111 [ian@attic-f21 ~]$ rpm -qad | wc -l 47711 [ian@attic-f21 ~]$ rpm -qa | grep -i fortran gcc-gfortran-4.9.2-6.fc21.x86_64 libgfortran-4.9.2-6.fc21.x86_64 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. 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). Which package supplies the vim executable [ian@attic-f21 ~]$ which vim /usr/bin/vim [ian@attic-f21 ~]$ rpm -qf `which vim` vim-enhanced-7.4.475-2.fc21.x86_64 [ian@attic-f21 ~]$ rpm -qf $(which vim) vim-enhanced-7.4.475-2.fc21.x86_64 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. Learn Linux, 101: RPM and YUM package management Page 13 of 25 developerWorks® ibm.com/developerWorks/ 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. 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. What does gcc-gfortran require [ian@attic-f21 ~]$ rpm -qR gcc-gfortran /bin/sh /bin/sh /sbin/install-info /sbin/install-info gcc = 4.9.2-6.fc21 ld-linux-x86-64.so.2()(64bit) ld-linux-x86-64.so.2(GLIBC_2.3)(64bit) libc.so.6()(64bit) libc.so.6(GLIBC_2.11)(64bit) libc.so.6(GLIBC_2.14)(64bit) libc.so.6(GLIBC_2.2.5)(64bit) libc.so.6(GLIBC_2.3)(64bit) libc.so.6(GLIBC_2.4)(64bit) libdl.so.2()(64bit) libdl.so.2(GLIBC_2.2.5)(64bit) libgfortran = 4.9.2-6.fc21 libgfortran.so.3()(64bit) libgmp.so.10()(64bit) libm.so.6()(64bit) libmpc.so.3()(64bit) libmpfr.so.4()(64bit) libquadmath = 4.9.2-6.fc21 libquadmath-devel = 4.9.2-6.fc21 libz.so.1()(64bit) rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(PayloadIsXz) <= 5.2-1 rtld(GNU_HASH) 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. shows how to get the dependency list for just the version of gcc-gfortran that is installed. Using yum deplist to find what gcc-gfortran requires [ian@attic-f21 ~]$ rpm -q gcc-gfortran gcc-gfortran-4.9.2-6.fc21.x86_64 [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 Learn Linux, 101: RPM and YUM package management Page 14 of 25 ibm.com/developerWorks/ developerWorks® 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 . 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 bash.x86_64 gcc.x86_64 glibc.i686 glibc.x86_64 gmp.x86_64 info.x86_64 libgfortran.i686 libgfortran.x86_64 libmpc.x86_64 libquadmath-devel.i686 libquadmath-devel.x86_64 libquadmath.i686 libquadmath.x86_64 mpfr.x86_64 zlib.x86_64 If you just need to know what packages need to be installed, you can always run yum install 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. 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 Learn Linux, 101: RPM and YUM package management Page 15 of 25 developerWorks® ibm.com/developerWorks/ 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. What packages provide ld-linux-x86-64.so.2(GLIBC_2.3)(64bit) capability [ian@attic-f21 ~]$ rpm -q --whatprovides 'ld-linux-x86-64.so.2(GLIBC_2.3)(64bit)' glibc-2.20-8.fc21.x86_64 [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. shows an example for the vimenhanced RPM. Checking the integrity of the vim-enhanced package file [ian@attic-f21 ~]$ rpm -vK vim-enhanced-7.4.475-2.fc21.x86_64.rpm 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. [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 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) Learn Linux, 101: RPM and YUM package management Page 16 of 25 ibm.com/developerWorks/ developerWorks® 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 , 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. 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 . Tampering with the vim-common package [root@attic-f21 ~]# rpm -qf /usr/bin/xxd /usr/share/vim/vim74/syntax/bindzone.vim vim-common-7.4.475-2.fc21.x86_64 vim-common-7.4.475-2.fc21.x86_64 [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. shows how to reinstall with yum, and then verify that the package is now okay and the deleted file has been restored. 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 Learn Linux, 101: RPM and YUM package management Page 17 of 25 developerWorks® ibm.com/developerWorks/ Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Reinstalling: 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 Running transaction check Running transaction test Transaction test succeeded Running transaction (shutdown inhibited) Installing : 2:vim-common-7.4.475-2.fc21.x86_64 Verifying : 2:vim-common-7.4.475-2.fc21.x86_64 | 5.9 MB 00:03 1/1 1/1 Installed: vim-common.x86_64 2:7.4.475-2.fc21 Complete! [root@attic-f21 ~]# rpm -V vim-common [root@attic-f21 ~]# ls /usr/bin/xxd /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. 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. 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 Learn Linux, 101: RPM and YUM package management Page 18 of 25 ibm.com/developerWorks/ developerWorks® [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 /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 . In our case, the gcc-gfortran.x86_64 package is already installed, so there are no additional packages to download. 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 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 Learn Linux, 101: RPM and YUM package management Page 19 of 25 developerWorks® ibm.com/developerWorks/ ---> 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 . 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. shows how to do this for the gccgfortran 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. 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 ./usr/bin/f95 ./usr/bin/gfortran ./usr/lib/gcc ./usr/lib/gcc/x86_64-redhat-linux ./usr/lib/gcc/x86_64-redhat-linux/4.9.2 ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/32 ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/32/libcaf_single.a ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/32/libgfortran.a ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/32/libgfortran.so ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/32/libgfortranbegin.a ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/finclude ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/finclude/omp_lib.f90 Learn Linux, 101: RPM and YUM package management Page 20 of 25 ibm.com/developerWorks/ developerWorks® ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/finclude/omp_lib.h ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/finclude/omp_lib.mod ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/finclude/omp_lib_kinds.mod ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/libcaf_single.a ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/libgfortran.so ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/libgfortran.spec ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/libgfortranbegin.a ./usr/libexec/gcc ./usr/libexec/gcc/x86_64-redhat-linux ./usr/libexec/gcc/x86_64-redhat-linux/4.9.2 ./usr/libexec/gcc/x86_64-redhat-linux/4.9.2/f951 ./usr/share/doc/gcc-gfortran ./usr/share/doc/gcc-gfortran/ChangeLog-2002.bz2 ./usr/share/doc/gcc-gfortran/ChangeLog-2002.libgfortran.bz2 ... ./usr/share/doc/gcc-gfortran/ChangeLog.bz2 ./usr/share/doc/gcc-gfortran/ChangeLog.libgfortran.bz2 ./usr/share/doc/gcc-gfortran/ChangeLog.ptr.bz2 ./usr/share/info/gfortran.info.gz ./usr/share/man/man1/gfortran.1.gz 37373 blocks [ian@attic-f21 gcc-gfortran]$ find . | head . ./usr ./usr/lib ./usr/lib/gcc ./usr/lib/gcc/x86_64-redhat-linux ./usr/lib/gcc/x86_64-redhat-linux/4.9.2 ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/libcaf_single.a ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/finclude ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/finclude/omp_lib.h ./usr/lib/gcc/x86_64-redhat-linux/4.9.2/finclude/omp_lib.mod 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. 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. Learn Linux, 101: RPM and YUM package management Page 21 of 25 developerWorks® ibm.com/developerWorks/ 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. 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. 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 "$@"; retval=$?; else echo "bash: $1: command not found"; fi; return $retval } At the beginning of this tutorial, we showed you two different outputs from gfortran --help. The first showed you a response with command_not_found_handle disabled and the second was with it enabled. Go back and review 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. dnf 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: Learn Linux, 101: RPM and YUM package management Page 22 of 25 ibm.com/developerWorks/ developerWorks® 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. PackageKit 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. Gnome PackageKit graphical interface on Fedora 21 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 Learn Linux, 101: RPM and YUM package management Page 23 of 25 developerWorks® ibm.com/developerWorks/ (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. RELATED TOPICS: developerWorks roadmap for LPIC-1 Learn Linux, 101: RPM and YUM package management Linux Professional Institute RPM Page 24 of 25 ibm.com/developerWorks/ developerWorks® About the author Ian Shields Ian Shields is a freelance Linux writer. He retired from IBM at the Research Triangle Park, NC. Ian joined IBM in Canberra, Australia, as a systems engineer in 1973, and has worked in Montreal, Canada, and RTP, NC in both systems engineering and software development. He has been using, developing on, and writing about Linux since the late 1990s. His undergraduate degree is in pure mathematics and philosophy from the Australian National University. He has an M.S. and Ph.D. in computer science from North Carolina State University. He enjoys orienteering and likes to travel. © Copyright IBM Corporation 2010, 2015 (www.ibm.com/legal/copytrade.shtml) Trademarks (www.ibm.com/developerworks/ibm/trademarks/) Learn Linux, 101: RPM and YUM package management Page 25 of 25