dcsimg

Linux Software Management with yum

With the pending release of RHEL 5, Red Hat is moving from up2date to yum. Learn the ins-and-outs of your next command line software manager.

Upgrading Software with Yum

With Yum installed and configured, you can begin using it. You might want to begin by typing the following command:

 # yum check-update

This command checks your system against the Yum repositories configured in /etc/yum.conf and /etc/yum.repos.d/. The output of this command can be quite verbose. The command’s speed depends on the speed of your network connection and the load at the Yum repository sites. If your system needs no updates, the command returns a value of 0; if any packages need updates, the return value is 100 and the program displays a list of the packages that require updates. This command doesn’t actually download or install any packages, though.

yum check-update is a safe way to begin using yum; it shows you what the program will do when you use it to perform a system upgrade, but without actually modifying any installed packages. If you see error messages or spot upgrades you didn’t anticipate or don’t want, you can take measures to avoid the problems. For instance, you can upgrade individual packages rather than your whole system, as described shortly.

To upgrade all the packages on your system, you can type either of the following commands:

 # yum -y update
 # yum -y upgrade

These commands have identical effects, except that the upgrade command activates logic in Yum for handling obsolete packages. (This same feature can be activated by using the ––obsoletes option along with update.) This obsolete package handling is most important when you’re performing a major upgrade, such as upgrading from one version of your distribution to the next one.

These examples use the –y option, which tells Yum to automatically provide a y (“yes”) response to questions asked by Yum. Because “yes” is normally the response you’d give, this can speed up the process of using Yum, but it does increase the risk of problems arising as a result of incorrect automatic “yes” responses. You can change the default by editing the assume-yes option in /etc/yum.conf.

Be aware that system updates and upgrades can download many packages, and some of them can be quite big. Thus, you might want to be careful about performing such updates if you’ve got a slow network connection or if you have little time to spare nursing Yum through the update process. With luck, there will be no problems, but you can never really be sure of that — packages can fail to download or install for any number of reasons, so you might need to re-run the command, remove conflicting packages, or otherwise fix problems.

If you don’t want to update all the packages on your system, you can update just one, as well as any dependencies that need updating, by specifying its name:

 # yum update target-package

This command updates target-package and its dependencies, but nothing else. If you want to see what dependencies might be updated, use check-update rather than update to have Yum report all the packages it will update. You can update multiple packages by specifying them all on one command line.

Installing Software with Yum

As Linux distributions have grown in size, one of the annoyances that’s grown with them is the need to swap CD-ROM’s to locate packages for upgrades. You can avoid this problem by using Yum to grab new packages from Yum repositories on the Internet. To do so, use the install subcommand and name your package:

 # yum install target-package

This command installs target-package on your computer, provided that a package by that name is present in the Yum repositories specified in your Yum configuration file.

In addition to the target package itself, this command installs any packages upon which it depends, if they’re not already installed. Thus, this command can end up installing quite a few packages. You should be aware of this possibility, particularly if your network link is slow.

Yum and x86-64 Systems

If you’re using an x86-64 system rather than a PowerPC, 32-bit x86, or other platform, you should be aware of an extra factor with Yum: By default, Yum install both 32-bit and 64-bit versions of a package, if both are available. In other words, if you type yum install target-package, Yum will look for and install both target-package- version.i386.rpm and target-package- version.x86_64.rpm.

If you know that you only need the 64-bit version of the package, you can force Yum to install only that version by appending the platform specification after a dot, as in yum install target-package.x86_64.

Most distributions make 32-bit versions of packages available for x86-64 versions of their distributions for just a few packages. Thus, you shouldn’t need to specify the architecture very often. Indeed, you should think hard before doing so; chances are if both versions are in the repository, it’s because the package is a library or other package that’s depended upon by other packages that are available only in 32-bit form.

Cleaning Up After Yum

Yum works, in part, by downloading RPMs from repository sites and then installing those packages. By design, though, Yum doesn’t clean up after itself– after installation, the package files remain behind in the Yum directory tree, /var/cache/yum. This enables you to quickly re-install a package if you delete it and then change your mind; however, tit also consumes a great deal of disk space. If you need to get that disk space back, you can do so by telling Yum to do some housecleaning:

 # yum clean packages

This command cleans out the package files, which are generally the biggest disk space hogs. Yum also maintains package header files and other data, though. If Yum begins behaving strangely, you might want to use headers, metadata, cache, or dbcache in place of packages in the preceding command. These options clean the specified types of data, in case they become corrupted or bloated.

Summing Up

All in all, Yum is a great tool for simplifying maintenance of RPM-based systems. By adopting a network-based package management tool, you can more easily keep up with bug fixes (especially security-related bug fixes), install new software, and so on.

This column has described the most important and useful Yum features; however, it supports additional options. You might want to consult the Yum man page, as well as the man page for /etc/yum.conf, to learn more about this useful tool.

Comments are closed.