In its simplest form, RPM can be used to install packages:
The next simplest command is to uninstall a package:
rpm -i foobar-1.0-1.i386.rpm
rpm -u foobar
One of the more complex but highly useful commands allows you to install packages via FTP. If you are connected to the net and want to install a new package, all you need to do is specify the file with a valid URL, like so:
rpm -i ftp://ftp.pht.com/pub/linux/redhat/rh-2.0-beta/RPMS/foobar-1.0-1.i386.rpm
Please note, however, that the current version of RPM will only do installs via FTP. You cannot run any of the more complex query options on packages at an FTP site.
While these are simple commands, rpm can be used in a multitude
of ways as seen from the
rpm version 1.4.5 Copyright (C) 1995 - Red Hat Software This may be freely redistributed under the terms of the GNU Public License usage: rpm --help rpm --version rpm --install -i [-v] [--hash -h] [--percent] [--force] [--test] [--search] [--root <dir>] file1.rpm ... filen.rpm rpm --upgrade -U [-v] [--hash -h] [--percent] [--force] [--test] [--search] [--root <dir>] file1.rpm ... fileN.rpm rpm --query -q [-afFpP] [-i] [-l] [-s] [-d] [-c] [-v] [--root <dir>] [targets] rpm --verify -V -y [-afFpP] [--root <dir>] [targets] rpm --uninstall -u [--root <dir>] package1 package2 ... packageN rpm -b[plciba] [-v] [--short-circuit] [--clean] [--keep-temps] [--test] [--time-check <s>] specfile rpm --rebuild [-v] source1.rpm source2.rpm ... sourceN.rpm rpm --where package1 package2 ... packageN
First, I'll go through a synopsis of what all the options mean (don't worry, there may be alot of options, but we tried to make them all as intuitive as possible).
Options are nested, so the possible options are many. Here's a description
in parallel with the
helpprints the usage message
-iinstalls an rpm file.
--hash, -his a very cool option for watching the package install (much like 'hash' in ftp).
--percentprints the percentages as a package installs (but is only useful for interfacing with other tools...is not really human readable).
--forcewill force an install of a binary package even though it may already exist in the database.
--testwill tell you if installing would work or not (do you have a conflict with an already installed package).
--rootwill install a package using the root prefix specified instead of using the default of
--installinstalls an rpm file.
-Uupgrades a package. This option installs the new package and then uninstalls the old one without hurting the new one. The upgrade option takes the same options as the install option.
-qis the query option. In its simplest form, you can do
rpm -q foobarwhich would return
foobar-1.0-1. (1.0 is the version number, 1 is the release number.)
-awill query all currently installed packages.
-f <file>will query the package owning <file>.
-Fis the same as
-fexcept you can give it filenames via stdin (ie.
ls /usr/bin | rpm -qF).
-p <packagefile>will query the package. It is really only useful when combined with one of the Information Selection Options below.
-Pis like -p, except it takes its package filenames from stdin (ie.
ls /mnt/redhat/redhat-2.0/RPMS | rpm -qP).
--rootwill query a mounted filesystem.
-idisplays package information such as Name, Description, Release, etc.
-lwill display the file list from the entire package (all files that get installed). You can also use a
-vwith this to make the file list much more verbose.
-sshows you the state of all the files in the package. There are only two possible states, normal and missing.
-doutputs a list of just the files marked as documentation (man pages, info pages, READMEs, etc).
-vwill give even more info.
-coutputs a list of only the configuration files (sendmail.cf, passwd, inittab, etc.)
-vwill give more info about the files.
-V,-y,--verifyare the verify options. All are interchangeable. They all take the same Package Specification and Information Selection options as the
-qoption. I'll list some examples:
rpm -yf /bin/vi
rpm -Vp foobar-1.0-1.rpm
--uninstall, -u <package>to uninstall a package
-bto build a package (from sources and a spec file). This option will be discussed more at length in the next section, Building RPMs.
-vbe verbose in the output of what's going on.
-vvbe very verbose in the output of what's going on.