# rpm -qa | grep mail | sort

fetchmail-6.3.8-3.fc8

mailcap-2.1.25-1.fc8

mailx-8.1.1-46.fc7

procmail-3.22-20.fc8

sendmail-8.14.1-4.2.fc8

This example returns a sorted list of all packages with names containing the word mail.

NOTE

Another essential feature of the rpm command is its --rebuilddb option. If your system's RPM database becomes corrupted, this is your first (and perhaps only) option for restoring software management services. We hope that you never have to use this option; help ensure that by always backing up your data!

Extracting a Single File from an RPM File

Occasionally, it is useful to extract a single file from an RPM package. You can do so using the command- line version of mc, the Midnight Commander. In Figure 34.1, the Midnight Commander displays the contents of the yum RPM file. The Midnight Commander is a UNIX clone of the famous DOS Norton Commander, a file management utility. Using mc, just highlight the RPM file and press Enter; the contents of the RPM file are displayed. In the listing, you can browse the file structure of the RPM file and use mc to copy files from it.

FIGURE 34.1 A classic two-panel directory view and drop-down menus betray Midnight Commander's DOS inspiration, but it's a full-featured Linux file manager.

You might want to know what an .rpm script will do before you install the application. You can use the F3 key in mc to view the script files. If you want to look at the scripts without using mc, use this command:

# rpm -q --scripts filename > scripts.txt

This command pipes the scripts into a file, where you can examine it with a text editor. You could also pipe it to the less pagination command to view the scripts on your display:

# rpm -q -scripts filename | less

Getting Started with yum

As noted earlier, yum acts like a wrapper around rpm, allowing you to work easily with multiple files, both to install and include dependencies. This section introduces you to yum and makes sure you have the basics.

yum

yum is controlled entirely from the command line, so you have to memorize some useful switches to get the most from it. But before you go into yum itself, it is worth while understanding what goes on behind the scenes. How does yum actually work?

It is easiest to think of yum as a software layer that utilizes the rpm command. When you issue commands to yum, it automatically accesses various repositories and down loads the rpm headers that you requested and then queries them with the rpm command. The advantage to this is that all the processing takes place locally, without the need to download the entire RPM itself. Typically, the RPM header makes up a very small portion of the file, which makes it easy to handle and quick to download. yum builds and maintains a local cache of header files, attributed to the supplying repository, and queries this when you use yum. Each time yum is invoked, it checks the repositories for any updates. If any are found, it adds new headers to its cache, thereby making it as up-to-date as possible when you need to use it. Because yum uses rpm, there should be no dependency problems, making it a fast and easy way to install and update software.

yum is primarily controlled by its configuration file, yum.conf, and by the contents of the yum.repos.d directory, both of which can be found in /etc. By default, yum uses the Fedora repositories for updates, but you can easily add more of your own if you want to install other software that is not available from the default repositories. yum is incredibly easy to use, requiring a single command with a switch to update all the software in Fedora.

To get going with yum, you will need to open a terminal. Check that yum is installed and working by simply typing the following:

$ yum

This brings up the usage options for yum and lets you know that you have it installed.

After you have verified that yum is available, you should switch to super user and enter the following command:

# yum check-update

This command initializes yum and asks it to scan the installed RPMs on your machine, scan the repositories for header files, and then start building a cache of header files. After several minutes of frantic activity, yum will have completed its local cache of header files and will be ready for you to start downloading and installing updates and new software.

To perform a quick and easy update of all the software on your system, enter the following command:

# yum update

This asks yum to download header information from the registered repositories, check that against your currently installed packages, and update any that are marked as having new versions. This can take some time, depending on how often you run the command and how many packages you have installed on your system.

When yum has finished downloading the headers and working out dependencies, you are prompted with a list of the packages to be updated or installed and asked to give the go-ahead. Enter y at the command prompt and yum commences downloading the RPM files.

After the download finishes, yum runs the installation and a test to ensure that everything completed correctly. When yum is satisfied that everything is present and correct, you are returned to the command prompt with a freshly updated system.

This is great when you want to update your entire system, but what if you want to update only certain packages? Again, yum can easily take care of this for you. You can identify the package you want and then use yum to check for its availability by using the command shown here:

# yum list <packagename>

This command asks yum to cross-reference the package name with packages registered at the repositories and let you know what is available. You can use wildcards as part of the command to find out which associated packages are available. For instance, the command

Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату