Exploring the yum package manager


© Elena Elisseeva, Fotolia

© Elena Elisseeva, Fotolia

Article from Issue 103/2009

Install and manage packages from the command line with the powerful yum package manager.

Yum (Yellow Dog Updater, Modified) runs on Fedora and Yellow Dog Linux as an interface to the underlying RPM system. You can think of yum as something like the apt package manager found on Debian-based systems. If you favor a graphical approach, yum graphical front-ends include pirut (Figure 1), gyum, yum extender (Figure 2), and kyum; however, if you are familiar with a few basic yum commands, you might find that yum is faster and easier without the GUI. In this article, I'll help you get started with command-line Yum.

Figure 1: Fedora uses the pirut front-end as its default package manager.
Figure 2: If pirut is too spartan for your taste, try yum extender.

The yum package manager is really easy to use. To install a package, type yum install package_name; you can specify any number of packages at the same time. For example, to install the Pingus game, type yum install pingus.

To check the dependencies, yum starts by loading the header files with the package metadata for the new package as a background operation. After resolving the dependencies, yum lists the additional package requirements (Listing 1). Then the tool asks you to confirm that you want to start the installation; if so, type Y. If the installation is successful, yum will output a Complete! message to confirm that the packages were installed correctly.

Listing 1

Installing with yum

Dependencies Resolved
 Package                 Arch       Version          Repository        Size
 pingus                  i386       0.7.0-0.4.20060721.fc6  fedora      18 M
Installing for dependencies:
 ClanLib                 i386       0.8.0-4.fc7      fedora            1.2 M
 SDL                     i386       1.2.12-1.fc7     updates           219 k
 SDL_gfx                 i386       2.0.13-8.fc7     fedora             52 k
Transaction Summary
Install     11 Package(s)
Update       0 Package(s)
Remove       0 Package(s)
Total download size: 31 M
Is this ok [y/N]:

If you don't like answering Yes/No prompts, you can specify the -y option to say yes automatically to all questions:

yum -y install pingus

If you are removing packages, it pays to be careful; automatically removing dependencies can have unpleasant side effects.

By default, yum will install from the configured package sources (e.g., DVD, Internet repositories). You can also install individual RPM files with yum instead of rpm. Again, yum will check for dependencies and reference the repositories to add any missing packages automatically. The command line for this is:

yum localinstall package_name

Yum also makes life easier if you need to remove a package by deleting any components you no longer need. With the example of the Pingus game installation, yum adds sdl and ClanLib.

If you want to remove these packages, you must explicitly tell the RPM command to do this:

rpm -e pingus SDL Clanlib ....

Because you typically learn the dependencies for the packages you are removing from RPM's error messages, this approach can be time-consuming. In contrast, yum remove ClanLib will list the packages to uninstall, including their dependencies. Yum quickly prompts you to confirm that you want to uninstall all the listed packages and then does so if you say yes.

Update Packages

To update a package – or all packages – use the yum update package_name or yum update command. If you prefer a GUI, launch the Package Updater, pup, from a console through the desktop menu. Pup is part of the pirut package, which you set up via yum install pirut.

The yum update daemon will even update the whole system. To allow this to happen, you need to set the do_update entry to yes in your /etc/yum/yum-updatesd.conf configuration file (Listing 2). At boot time, chkconfig tells you whether or not the updatesd service is launched automatically:

# chkconfig --list | grep -i yum

The output shows the runlevel the service is enabled in; you can type runlevel to identify the current runlevel. To enable automatic start-up when you boot, type chkconfig yum-updatesd on. To start the daemon once only, type service yum-updatesd start.

Most often, you are likely to use the command yum search keyword, command searches the package names and details of all available packages for the keyword. To restrict the search to the package names, you can type yum list | grep keyword.

Listing 2


# how often to check for new updates (in seconds)
run_interval = 3600
# how often to allow checking on request (in seconds)
updaterefresh = 600
# how to send notifications (valid: dbus, email, syslog)
emit_via = dbus
# automatically install updates
do_update = yes
# automatically download updates
do_download = no
# automatically download deps of updates
do_download_deps = no

Yum Shell

If you need to complete a couple of chores one after another, the yum shell is the best place to do it. The shell lets you enter a number of actions in sequence without waiting for the previous action to complete. A typical scenario is a session in which you delete the cache, install packages, and remove other packages.

To launch the shell, type yum shell. The prompt accepts all the normal commands, such as install, remove, or update. Typing run launches the batch sequence you entered previously. When you are done, you can quit the shell by typing quit. Another use for the yum shell is to invoke a pipe to install something directly from a shell script:

# echo -e "install pingus\n  run\n quit" | yum -y shell

Here documents are often used for this purpose. A here document is a special approach to redirecting commands to the stdin channel of a program (Listing 3). Unlike the normal echo command, this method keeps most indents and newlines.

Listing 3

Here Document

#yum -y shell <<EOF
clean all
install ...
remove ...

You might need to download a number of RPM packages that you will be installing later on, or that you need to install on several identical machines. The yumdownloader tool from the yum-utils package is useful for this. To download the Pingus game, just type yumdownloader pingus. Yumdownloader will drop the specified package into the current working directory. Then you can enter

# yum localinstall pingus-0.7.2-3.fc10.i386.rpm

to install and resolve the dependencies. If you want to resolve the dependencies at the download stage, call yuminstaller with the --resolve option.

Yum is also perfect for downloading source packages that you will be building manually. To do so, use the --source option

# yumdownloader  --source pingus

to create an RPM file called pingus-0.7.2-3.fc10.i386.rpm in the current directory. To install, type:

# rpm -ihv pingus-0.7.2-3. fc10.i386.rpm

This command drops the source archive into /usr/src/redhat/SOURCES/, where you can unpack and build the application yourself.


When launched, yum updates the header files; it will always download the headers, even if you are installing the package multiple times. To avoid redundancy, you can enable header and package file caching. To do so, enable the keepcache=1 option in the /etc/yum.conf configuration file. If you then call yum with the -C option, yum will access the cache regardless of the /etc/yum.conf settings. Of course, this will only work if you really do have the required resources in the cache. If resources are missing, yum will give you the message Caching enabled but no local cache of ….

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Installing Software

    We provide an introduction to installing and managing RPM packages.

  • Fedora Core 5

    Fedora opens the spring fashion season with a bold new release. We took a look at the latest collection.

  • Fedora Core 3 Preview

    Version 3 of Red Hat’s free community-supported Fedora Core distribution will be available by the time you read this article.On the surface, very little has changed,but under the hood,Core 3 has innovations designed to improve the user experience.We investigated the final release candidate,and here’s what we found.

  • Smart Package Manager

    The package manager is one of the central components on any Linux system. If you have a system with unreliable package management – such as Suse Linux 10.1 – you may want to consider the Smart alternative.

  • Getting Rid of Old Kernels

    When you update the kernel, the old version remains on the disk. If you clean up, the reward is several hundred megabytes of free disk space.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More