Exploring the yum package manager
Delicious
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.
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 ============================================================================= Installing: 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]: ... Complete!
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
yum-updatesd.conf
[main] # 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 ... run quit EOF
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.
Caching
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
(incl. VAT)
Buy Linux Magazine
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.
News
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.
-
Plasma Desktop Will Soon Ask for Donations
The next iteration of Plasma has reached the soft feature freeze for the 6.2 version and includes a feature that could be divisive.
-
Linux Market Share Hits New High
For the first time, the Linux market share has reached a new high for desktops, and the trend looks like it will continue.
-
LibreOffice 24.8 Delivers New Features
LibreOffice is often considered the de facto standard office suite for the Linux operating system.
-
Deepin 23 Offers Wayland Support and New AI Tool
Deepin has been considered one of the most beautiful desktop operating systems for a long time and the arrival of version 23 has bolstered that reputation.