Exploring the yum package manager
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.
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.
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.
[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
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.
#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.
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
New partnership will bring more and better CS training to US schools
Criminals offer online help over Tor network
Sophisticated malware is still present on Joomla and WordPress sites around the world.
Future versions of Ubuntu's code service will support the popular Git version control system used with Linux and other open source projects.
New release marks the arrival of AMD’s unified driver strategy.
A new study by IDC charts big changes in the big hardware market.
Azure CTO says Redmond has already considered the unthinkable.
Lead developer quells rumors that the Debian version is slated for center stage.
MSBuild is now just another GitHub project as Redmond continues its path to the light.
Malware could pass data and commands between disconnected computers without leaving a trace on the network.