RPM installation, updation and removal will have to be done as root.
Querying the database does not require you to be root.
A basic installation of an RPM file can be accomplished by
rpm -ivh
e.g - rpm -ivh foo-1.03.rpm
At this point rpm will go out and check whether the files required by foo
are installed on the system or not. If some other package needs to be
installed then it will inform you of the requirements and exit. If some
files from the package have been installed by some other package then you
will be notified of that also.
Multiple files can also be specified using wildcards so the following is
also legal.
rpm -ivh foo*.rpm
Let's look at the options specified.
-i
Specifies installation as the action to be taken.
-v
Will display additional information while installing.
-h
Prints 50 hash marks (#) as installation progresses.
You can get by with just -i but it is generally a good idea to specify -v
and -h too so that you get proper feedback.
Other options that may be given are
--replacepkgs
Sometimes you may need to re-install a package that has been damaged then you need to specify this option. If you try an installation then rpm will say that the package is already installed.
--replacefiles
If you get a package with newer versions of a file and you would like to install it then use this option to replace the files.
--force
Force the installation to go ahead regardless of any errors. Failed dependencies will still stop it though.
--nodeps
Package dependencies are any packages that are required by a certain software. Fetchmail may require sendmail or some other mail server to be present on your system. Sendmail is the package dependency for fetchmail. You might have some other mail server installed, like Postfix, and you want to go ahead and install fetchmail. Adding --nodeps to the command line tells rpm to skip the checkup for any dependency packages and to go ahead and install fetchmail. Note that this can be dangerous, unless you know what you are doing.
Another place this option is very useful is when you have packages that require each other. So package A will say that package B should be installed, but package B will want A to be installed first. Just install one of the packages with --nodeps before you go on to install the other one.
RPM can also install over the net. If you happen to know the full url of your rpm file then just enter the following to get and install the package.
You will be prompted for the password after which the file will be downloaded and installed.
Updating
Updating your current package installation. If you come across a updated package then upgrading would be the right choice. Syntax is pretty much the same as installation. The default behaviour of this command is that rpm will first check for a older version of the package. If one is found then that package is updated otherwise normal installation is done. This is the recommended command to use because it prevents you from installing multiple versions of the same package.
rpm -Uvh filename.rpm
Un-Installation
An package installed via rpm can be uninstalled by
rpm -e <package_name>
The package name would be the name of the package at installation. For example
# rpm -e gpm
would remove the package named gpm.
Occasionally you might get dependency errors when removing packages that are required by other packages. You may use --nodeps here too tell rpm to ignore such dependency errors and uninstall the package regardless, but again, you must be cautious.
Query
Query allows you to query the RPM database for various information on a particular RPM. Generally a query is given with the -q followed by a query option.
If you want to check out the version of the installed package then simply run a '-q' on the package.
$ rpm -q samba
- samba-2.0.6-62
If you have a file which you wish to query and find out what package it belongs to, you can use the "-f" option
# rpm -qf /usr/sbin/smbd
-samba-2.0.6-62
You can veiw the information on a particular package on your system using the "-i" option. Here is an example for the crontabs package:
[hart@einstein hart]$ rpm -qi crontabs
Name : crontabs Relocations: (not relocateable)
Version : 1.10 Vendor: Red Hat, Inc.
Release : 5 Build Date: Fri 07 Feb 2003 02:07:32 PM MST
Install Date: Tue 01 Jul 2003 02:19:54 PM MST
Build Host: porky.devel.redhat.com
Group : System Environment/Base?
Source RPM: crontabs-1.10-5.src.rpm
Size : 1004 License: Public Domain
Signature : DSA/SHA1, Sun 23 Feb 2003 10:41:06 PM MST,
Key ID 219180cddb42a60e
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Summary : Root crontab files used to schedule the execution of programs.
Description :
The crontabs package contains root crontab files. Crontab is the
program used to install, uninstall, or list the tables used to drive the
cron daemon. The cron daemon checks the crontab files to see when
particular commands are scheduled to be executed. If commands are
scheduled, then it executes them.
You can view all of the files in a particular package installed on your system using the "-l" option:
You can also list all of the packages installed on your system using the "-a" option. This option will likely give you a rather extensive listing. As a result, you will generally want to grep this for something you are looking for. For example, if I wanted to search for any package that included "http" in it's name:
For normal usage, the above commands will do most of your work. RPM has a wealth of options. The man page is a good place to study all these options and see what can work for you.
You may also find the following links of interest: