In its simplest form, RPM can be used to install packages:
rpm -i foobar-1.0-1.i386.rpm
The next simplest command is to uninstall a package:
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 Usage
message:
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 Usage
message:
help
prints the usage message-i
installs an rpm file.
--hash, -h
is a very cool option for watching the package
install (much like 'hash' in ftp).--percent
prints the percentages as a package installs (but is
only useful for interfacing with other tools...is not really human
readable).--force
will force an install of a binary package even
though it may already exist in the database.--test
will tell you if installing would work or not (do you
have a conflict with an already installed package).--root
will install a package using the root prefix
specified instead of using the default of /
.--install
installs an rpm file.-U
upgrades 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.-q
is the query option. In its simplest form, you can
do rpm -q foobar
which would return foobar-1.0-1
. (1.0 is
the version number, 1 is the release number.)-q
:
-a
will query all currently installed packages.-f <file>
will query the package
owning <file>.-F
is the same as -f
except 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.-P
is like -p, except it takes its package filenames
from stdin (ie. ls /mnt/redhat/redhat-2.0/RPMS | rpm -qP
).--root
will query a mounted filesystem.-i
displays package information such as Name,
Description, Release, etc.-l
will display the file list from the entire
package (all files that get installed). You can also use a -v
with
this to make the file list much more verbose.-s
shows you the state of all the files in the package. There
are only two possible states, normal and missing.-d
outputs a list of just the files marked as
documentation (man pages, info pages, READMEs, etc). -v
will give
even more info.-c
outputs a list of only the configuration
files (sendmail.cf, passwd, inittab, etc.) -v
will give more info
about the files.{-V,-y,--verify}
are the verify options. All are interchangeable.
They all take the same Package Specification and Information Selection
options as the -q
option. I'll list some examples:
rpm -yf /bin/vi
rpm -ya
rpm -Vp foobar-1.0-1.rpm
--uninstall, -u <package>
to uninstall a package-b
to build a package (from sources and a spec file).
This option will be discussed more at length in the next section,
Building RPMs.-v
be verbose in the output of what's going on.-vv
be very verbose in the output of what's going on.Next Chapter, Previous Chapter
Table of contents of this chapter, General table of contents
Top of the document, Beginning of this Chapter