Feb. 15, 2011, 2:48 a.m.
posted by jack
The basic ways of using the rpm command to install, upgrade, and delete packages are covered in many introductory books on Fedora and Red Hat Linux (such as the Red Hat Linux Bible). By way of review, and for troubleshooters who are new to Linux, here are a few basic ways to use the rpm command.
If the package you want is in a yum or apt repository, I recommend you use the appropriate yum or apt tools to install the package. See Chapter 3 for descriptions of yum and apt.
The most common way to install a new package or upgrade an existing package is by using the -U option of rpm. With the file you want to install in the current directory, type the following:
# rpm -Uhv packagename-1.1.1.i386.rpm
If the package (represented by packagename-1.1.1.i386.rpm) is not yet installed, this command will install it. If it is a later version of an already installed package, the command will also install it (actually, upgrade it). The -h option prints hash marks (for positive feedback as the package installs) and -v gives verbose output (add multiple v's to see even more verbose output, such as -Uhvvv).
Instead of -U you can use the -i option to install a package. If it is a package that is not yet installed on your computer, it should install just fine. If the package (or an earlier version) is already installed, the install will fail and you will have to use -U to install it. For installing kernel packages, always use the -i option.
A great option when you are upgrading a whole lot of packages on an existing system is the freshen (-f) option. Let's say that you download a directory of packages with security updates, but you only want to install new versions of packages that are already installed. With that directory as the current directory, you could type the following:
# rpm -Fvh *.rpm
Packages that are already installed on your computer, but for which there are later versions in the current directory are installed. All other packages in the directory are not installed. (Keep in mind that packages not installed are skipped silently.)
To delete an installed package, use the -e (erase) option to rpm. For example,
# rpm -e Wnn6-SDK-devel
Again, the deletion of the package is done silently. So if you want positive feedback, add one or more -v options (for example, rpm -evvv).
There are a lot of options to the rpm command that you can use during basic package installs, upgrades, freshens, and deletions. Again, I'd recommend the Red Hat Linux Bible or the rpm man page for details about rpm options. Here are a few options you can use with basic install, upgrade, freshen, and delete options:
Saving space-You can save some space by excluding certain files from being installed from a package. In particular, --excludedocs excludes any files marked as documentation from being installed and --excludepath PATH excludes any files in the specified path from being installed.
Verbose-Add a single -v option to make the output more verbose. Add multiple -v options (-vv, -vvv, and so on) to see lots of debugging output.
install it anyway-There are several reasons that a package installation may fail, almost all of which can be overridden. On a production machine, you should probably fix the problem before continuing (as in, fix the dependency).
However, on a noncritical computer where you just want to check out a package, you can skip dependency checking (--nodeps), not verify any digests (-nodigests), and not verify signatures (--nosignature). You can even skip checking for sufficient disk space (--ignoresize) and install despite having binaries intended for a different computer architecture (--ignorearch).
Dependency, digest, signature, and architecture checks are all put in to make sure that you are installing software that is safe and correct for your environment. Overriding these safeguards can be dangerous. Do so at your own risk.
Watch progress-There are several options for watching the progress of a package installation. You can print 50 hash marks (#) as rpm unpacks a package archive using the -h option. Likewise, you can tell rpm to print the percentage at which the file was unpacked with the -percent option.
Test it-Before you go ahead and do a real install or uninstall of a package, you can test it using the --test option. I recommend you add one or more -v options to get as much information as possible before running the install or uninstall for real.
Now that you have had a quick review of the basics, the rest of this chapter is devoted to learning how to prevent and track down problems with software packages.