One of the mundane, yet necessary, duties a Systems Administrator faces is software management. Applications and patches come and go. After months or years of adding, upgrading, and removing software applications, it's hard to tell just what's on a system, what version a software package is, and what other applications it depends on. Outdated files often wind up laying around because nobody's quite sure what they belong to. Worse, you may install a new software package only to find it has overwritten a crucial file from a currently installed package. The Red Hat Package Manager (RPM) was designed to eliminate these problems. With RPM, software is managed in discrete “packages,” a collection of the files that make up the software, and instructions for adding, removing, and upgrading those files. RPM also makes sure you never lose configuration files by backing up existing ones before overwriting. RPM also tracks which version of an application is currently installed on your system.
A key feature of RPM is that filenames can be specified in Uniform Resource Locator (URL) format. For example, if you know that the package foo.rpm is on the FTP server ftp.rpmdownloads.com, in the /pub directory, you can specify that filename as ftp://ftp.rpmdownloads.com/pub/fee.rpm.RPM is smart enough to log on to the FTP server
anonymously and pull down the file. You can also use the format
ftp://<username>:<password>@hostname:<port>/path/to/remote/package/file.rpm, where <username> and
<password> are the username and password you need to log on to this system non-anonymously, and <port>
specifies a nonstandard port used on the remote machine. You may use these formats anywhere a filename is called for in RPM.
10.2 What Is a Package?
In the generic sense, a package is a container. It includes the files needed to accomplish a certain task, such as the binaries, configuration, and documentation files in a software application. It also includes instructions on how and where these files should be installed, and how the installation should be accomplished. A package also includes instructions on how to uninstall itself. RPM packages are often identified by filenames that usually consist of the package name, the version, the release, and the architecture for which they were built. For example, the package penguin-3.26.i386.rpm indicates this is the (fictional) Penguin Utilities package, version 3, release 26.
i386 indicates it has been compiled for the Intel architecture. Note that although this is the conventional method of naming RPM packages, the actual package name, version, and architecture information are read from the which files to handle, and where to put them.
RPM also takes care of conflicts between packages. For example, if package X, which has already been installed, has a configuration file called /etc/someconfig, and you attempt to install a new package, Y, which wants to install the same file, RPM will manage this conflict by backing up your previous configuration file before the new file is written. The workhorse of the RPM system is the program rpm. rpm is the “driver” responsible for maintaining the RPM databases. Of rpm's 10 modes of operation, we will cover the four most common: query, install, upgrade, and remove
10.3.1 Listing Installed RPMs
The rpm -qa command will list all the packages installed on your system [root@skynet tmp]# rpm -qa
perl-Storable-1.0.14-15 smpeg-gtv-0.4.4-9 e2fsprogs-1.27-9 libstdc++-3.2-7
Linux Administration – RedHat Package Management Page 56 of 167
You can also pipe the output of this command through the grep command if you are interested in only a specific package. In this example we are looking for all packages containing the string "ssh" in the name, regardless of case ("-i" meaning ignore case)
Note: You could use the "rpm -q package-name" command to find an installed package as it is much faster than using grep and the "-qa" switch, but you have to have an exact package match. If you are not sure of the package name and its capitalization, then the method above is probably more suitable.
10.3.2 Listing Files Associated With RPMs
Sometimes you'll find yourself installing software which terminates with an error requesting the presence of particular file. In many cases the installation program doesn't state the RPM package in which the file can be found. It is therefore important to be able to determine the origin of certain files, by listing the contents for RPMs in which you suspect the files may reside.
10.3.4 Listing Files For Already Installed RPMs
This can be useful if you have to duplicate a working server that is already in a production environment.
Sometimes the installation of an application fails on the new server due to the lack of a file that resides on the old one. In this case you need to know which RPM on the old server contains the file.
You can use the "-ql" qualifier to list all the files associated with an installed RPM. In this example we test to make sure that the NTP package is installed using the"-q" qualifier, then we use the "-ql" qualifier to get the file listing.
[root@skynet tmp]# rpm -q ntp
10.2 Managing RPMs
(install, re-install, upgrade, erase etc.) Installing RPMsThe rpm -i command will install a package. The package name given must match that listed in the rpm -qa command as the version of the package is important. -v is used for verbose output and -h shows the process of installation as # (hashes)
Linux Administration – RedHat Package Management Page 57 of 167
Installing RPM without checking for dependency
[root@skynet tmp]# rpm -ivh --nodeps package-name.rpm Re-installing RPM
[root@skynet tmp]# rpm –ivh -–replacepkgs pkgname.rpm Upgrading RPMs
The rpm -U command will upgrade a package.
[root@skynet tmp]# rpm -Uvh package-name.rpm Uninstalling RPMs
The rpm -e command will erase an installed package. The package name given must match that listed in the rpm -qa command as the version of the package is important.
[root@skynet tmp]# rpm -e package-name.rpm
Linux Administration – Networking Page 58 of 167
www.wilshiresoft.com Wilshire Software Technologies Rev Dt: 15-Oct-08