December 21, Content series: This content is part of in the series: Learn Linux, https: This content is part of the series: Learn Linux, Stay tuned for additional content in this series.
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 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. Another tutorial in this series, " Learn Linux 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.
Linux Server Professional Certification exams. See " Learn Linux, 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.
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. 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. 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. So "an rpm" or "the xxx rpm" will generally refer to an RPM file, while rpm will usually refer to the command.
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. But if your system can't find gfortran, you might see output similar to that shown in. Install package 'gcc-gfortran' to provide command 'gfortran'?
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.
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.
Your dependencies may differ according to what you already have installed on your system. 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. In , YUM found the latest version of the gcc-gfortran package which happened to be the same level 4.
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?
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. 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.
The metadata about packages that is stored in the local database is retrieved from the enabled repositories. 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. If the package can be removed, there is no output. 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.
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. Delta RPMs reduced 3. 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. 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.
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. The gcc-gfortran package provides support for compiling Fortran: Mon 27 Jul Thu 12 Feb 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. As shown in , yum will list installed and available packages. 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.