These classnotes are depreciated. As of 2005, I no longer teach the classes. Notes will remain online for legacy purposes

UNIX01/RPM Usage

Classnotes | UNIX01 | RecentChanges | Preferences

Installation of an RPM

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.

 rpm -ivh ftp://ftp.linux.tucows.com/pub/RedHat/foo.rpm

If the site requires a valid login and password pair then you can enter that in the url too.

rpm -ivh ftp://yahoo@ftp.linux.tucows.com/put/RedHat/foo.rpm

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:

 $ rpm -ql samba
 /usr/bin/addtosmbpass
 /usr/bin/convert_smbpasswd
 /usr/bin/mksmbpasswd.sh
 /usr/bin/smbadduser
 /usr/bin/smbpasswd
 /usr/bin/smbstatus
 ...etc.....

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:

 [hart@einstein hart]$ rpm -qa | grep http
 httpd-2.0.40-21.3
 httpd-devel-2.0.40-21.3
 libghttp-devel-1.0.9-7
 httpd-manual-2.0.40-21.3
 redhat-config-httpd-1.0.1-18
 libghttp-1.0.9-7

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:



Classnotes | UNIX01 | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited August 9, 2003 4:06 am (diff)
Search:
(C) Copyright 2003 Samuel Hart
Creative Commons License
This work is licensed under a Creative Commons License.