I'll discuss the venerable Red Hat Package Manager (RPM) because of its widespread use, because both Red Hat Enterprise Server and Novell's SUSE Linux use RPM, and because most package managers behave similarly. Keep in mind, however, that you can find other excellent package managers for Debian-based Linux (e.g., Advanced Packaging Tool—APT).
The RPM system relies on three components: an installation file known as an RPM package (in Windows, comparable entities are Windows Installer and InstallShield files); the rpm command; and the RPM database. Figure 1 shows the RPM installation process. The administrator runs the rpm command to read the RPM package. The RPM package installs files on the system and possibly modifies existing files. The rpm command then updates the RPM database with information about the installed RPM package.
When you use any package manager (e.g., RPM), you typically have three major operations available: queries, installation, and removal.
Querying packages. Windows administrators will envy one feature of most Linux package managers: the ability to query a package. That is, package managers such as RPM let you query a package or the RPM database to see which files are being installed and which scripts are being executed to install or remove the software.
Let's take as an example the rcs-5.7-860.i586.rpm RPM file, which installs several binaries and documentation files. (Software developers use the Revision Control System—RCS—to control revisions of their code.) To determine exactly which files are contained in the RPM package, you can run the following rpm command:
# rpm -qlp rcs-5.7-
86Ø.i586.rpm
/usr/bin/ci
/usr/bin/co
/usr/bin/ident
...
(The command wraps to several lines here because of space constraints.) Be aware that the RPM files have the format application-version.architecture.rpm. When you work with RPM files, you specify the full filename, but when you work with installed RPMs, you need to specify only application (you'll see this feature in action in subsequent examples).
Before you install RCS, you can see that the RPM will install /usr/bin/ci, /usr/bin/co, and /usr/bin/ident, along with several other files that the sample command doesn't show. You perform the query operation by specifying the -q (query), -l (list files), and -p (specify a package file to examine) options.
You can also use RPM to determine which package owns a given file. For example, you might perform a file audit to determine whether a given file is on your server. To determine which package owns a file, specify the options -q and -f (from file), as follows:
# rpm -qf /usr/bin/ci
rcs-5.7-860
Other query options are available (e.g., you can review which scripts a package will run to complete an installation). To learn more about the rpm command and various query options, read the rpm manpage.
Installing packages. With the knowledge you've gained from querying a package, you can now move forward to installing the package on the server. RPM makes this process simple—you simply specify the -i (install) option of the rpm command, as follows:
# rpm -i rcs-5.7-860.i586.rpm
If all goes well, no output occurs. (This approach is typical of Linux tools—only errors are printed.) Many administrators prefer to see the status of RPM installs, especially if the RPM is large and will take several minutes or more. To watch the progress of an installation, use the -h (hash) and -v ( verbose) options:
# rpm -ihv rcs-5.7-860.i586.rpm