Red Hat Linux 6.1: The Official Red Hat Linux Getting Started Guide | ||
---|---|---|
Prev | Chapter 6. Using Gnome-RPM and RPM | Next |
You can also use RPM technology by typing a vareity of commands at the shell prompt. At your disposal, of course, are all the functions available through Gnome-RPM, with some additions, such as the ability to freshen packages, which is similar to upgrading (refer to the section called Freshening for more information).
For more in-depth information about RPM, refer to the related chapters in the Official Red Hat Linux Reference Guide. You can also read the related man page by typing man rpm or the help file by typng rpm --help.
RPM packages typically have file names like foo-1.0-1.i386.rpm, which includes the package name (foo), version (1.0), release (1), and architecture (i386). Installing a package is as simple as typing:
# rpm -ivh foo-1.0-1.i386.rpm foo #################################### # |
RPM prints out the name of the package (which is not necessarily the same as the file name), and then prints a succession of hash marks as the package is installed as a progress meter.
Actually, you can also install a package with the upgrade option. For more information, see the section called Upgrading.
While installing, you could run into errors, such as statements that the package is already installed or that there are dependency problems which hinder the installation of the package.
For information about the types of errors you may encounter, read on.
If the package is already installed, you will see:
# rpm -ivh foo-1.0-1.i386.rpm foo package foo-1.0-1 is already installed error: foo-1.0-1.i386.rpm cannot be installed # |
If you want to install the package anyway, you can use --replacepkgs on the command line, which tells RPM to ignore the error:
# rpm -ivh --replacepkgs foo-1.0-1.i386.rpm foo #################################### # |
If you attempt to install a package that contains a file which has already been installed by another package, you'll see:
# rpm -ivh foo-1.0-1.i386.rpm foo /usr/bin/foo conflicts with file from bar-1.0-1 error: foo-1.0-1.i386.rpm cannot be installed # |
To cause RPM to ignore that error, use --replacefiles on the command line:
# rpm -ivh --replacefiles foo-1.0-1.i386.rpm foo #################################### # |
RPM packages can "depend" on other packages, which means that they require other packages to be installed in order to run properly. If you try to install a package for which there is such an unresolved dependency, you'll see:
# rpm -ivh bar-1.0-1.i386.rpm failed dependencies: foo is needed by bar-1.0-1 # |
To correct the error, you should install the requested package. If you want to force the installation anyway (a bad idea since the package probably will not run correctly), use --nodeps on the command line.
Uninstalling a package is also simple::
# rpm -e foo # |
Notice that when you uninstall a package, you should use the package name (foo) not the name of the original package ("foo-1.0-1.i386.rpm").
You can encounter a dependency error when uninstalling a package if some other installed package depends on the one you are trying to remove. For example:
# rpm -e foo removing these packages would break dependencies: foo is needed by bar-1.0-1 # |
To cause RPM to ignore that error and uninstall the package anyway (also a bad idea since the package that depends on it will probably fail to work properly), use --nodeps on the command line.
Upgrading a package is similar to installing.
# rpm -Uvh foo-2.0-1.i386.rpm foo #################################### # |
When you upgrade, RPM automatically uninstalls any old versions of the foo package.
You can use upgrade to install packages, as well, since it works fine even when there are no previous versions of the package installed.
Since RPM performs intelligent upgrading of packages with configuration files, you may see a message like:
# rpm -Uvh foo-1.0-1.i386.rpm foo package foo-2.0-1 (which is newer) is already installed error: foo-1.0-1.i386.rpm cannot be installed # |
To cause RPM to "upgrade" anyway, use --oldpackage on the command line:
# rpm -Uvh --oldpackage foo-1.0-1.i386.rpm foo #################################### # |
Freshening a package is similar to upgrading:
# rpm -Fvh foo-1.2-1.i386.rpm foo #################################### # |
RPM's freshen option checks the versions of the packages specified on the command line against the versions of packages that have already been installed on your system. When a newer version of an already-installed package is processed by RPM's freshen option, it will be upgraded to the newer version. However, RPM's freshen option will not install a package if no previously-installed package of the same name exists. This differs from RPM's upgrade option, as an upgrade will install packages, whether or not an older version of the package was already installed.
Querying the database of installed packages is accomplished with rpm -q. A simple use is rpm -q foo which will print the package name, version, and release number of the installed package foo:
# rpm -q foo foo-2.0-1 # |
Instead of specifying the package name, you can use the following options with -q to specify what package(s) you want to query. These are called Package Specification Options.
-a queries all currently installed packages.
-f <file> will query the package owning <file>.
-p <packagefile> queries the package <packagefile>.
There are a number of ways to specify what information to display about queried packages. The following options are used to select the type of information for which you are searching. These are called Information Selection Options.
-i displays package information such as name, description, release, size, build date, install date, vendor, and other miscellaneous information.
-l displays the list of files that the package "owns".
-s displays the state of all the files in the package.
-d displays a list of files marked as documentation (man pages, info pages, README's, etc).
-c displays a list of files marked as configuration files. These are the files you change after installation to adapt the package to your system (sendmail.cf, passwd, inittab, etc).
For those options that display file lists, you can add -v to your command line to get the lists in a familiar ls -l format.
Verifying a package compares information about files installed from a package with the same information from the original package. Among other things, verifying compares the size, MD5 sum, permissions, type, owner and group of each file.
The command rpm -V verifies a package. You can use any of the Package Selection Options listed for querying to specify the packages you wish to verify. A simple use is rpm -V foo which verifies that all the files in the foo package are as they were when they were originally installed. For example:
To verify a package containing particular file:
rpm -Vf /bin/vi |
To verify ALL installed packages:
rpm -Va |
To verify an installed package against an RPM package file:
rpm -Vp foo-1.0-1.i386.rpm |
If everything verified properly there will be no output. If there are any discrepancies they will be displayed. The format of the output is a string of 8 characters, a possible "c" denoting a configuration file, and then the file name. Each of the 8 characters denotes the result of a comparison of one attribute of the file to the value of that attribute recorded in the RPM database. A single "." (period) means the test passed. The following characters denote failure of certain tests:
5 -- MD5 checksum
S -- File size
L -- Symbolic link
T -- File modification time
D -- Device
U -- User
G -- Group
M -- Mode (includes permissions and file type)
If you see any output, use your best judgment to determine if you should remove or reinstall the package, or otherwise fix the problem.