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
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.