RPM Commands

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search

REDHAT _ _ _ _ _ _ _ _ _ _ _

 _     ___ _   _ _   ___  __
| |   |_ _| \ | | | | \ \/ /
| |    | ||  \| | | | |\  / 
| |___ | || |\  | |_| |/  \ 
|_____|___|_| \_|\___//_/\_\ 

RPM COMMANDS
..............................................................................

RPM is an acronym for Red Hat Package Manger. It was developed by Redhat and is now being used by many Linux distributions.

QUICK COMMAND REFERENCE

Get a list of all RPM packages installed on system:

rpm -qa

Looking for a specific package or group of packages? Use grep:

rpm -qa|grep up2date

Remove an unwanted rpm package from the system:

rpm -e up2date-gnome-2.8.39-1.7.2

Forcing removal can be done by saying "don't do dependency check"

rpm -e --nodeps packagename

What's necessary or required for this package:

rpm -qR vim-minimal-6.1-18.8x.1.i386.rpm

Install a package:

rpm -i vim-minimal-6.1-18.8x.1.i386.rpm

Install with status and information:

rpm -ihvv --percent vim-minimal-6.1-18.8x.1.i386.rpm

List files in rpm package when the rpm has not been installed

rpm -qpl vim-minimal-6.1-18.8x.1.i386.rpm

Rebuild RPM database:

(solves "rpmdb: unable to join the environment" problem)
rpm --rebuilddb

Upgrade/Freshen

Using the freshen option is the same as upgrade except the package will only be upgraded if a previous version is installed. Upgrade will install the package even if a previous version does not exist.
rpm -F packagename.rpm
rpm -U packagename.rpm

 

WHAT PROVIDES?

(the file is in which rpm?)

When attempting to install an RPM and the install fails due to a missing dependency, one as to figure out which RPM is needed to supply the dependency (such as a file, library, or capability) in order to obtain it, install it, and then go back and try to install the original RPM file that first complained about the missing dependency.

The --whatprovides switch sounds promising, however, it only searches though the RPM files already on your system. Since the dependency is not fulfilled, then the RPM is not yet on the system, and therefore the switch seems rather stupid IMHO.

The following is an example of using --whatprovides

rpm -q --whatprovides XFree86-libs

Furthermore, --whatprovides searches for the "capability" where is the -f option searches for the specific file.

rpm -q -f xx

You can also download a package that looks promising and list the contents

 rpm -ql packagename

What if the package isn't on your system, installed, downloaded, or otherwise? You need to know which package to download and install so you can satisfy the dependency. This is a problem. There does not seem to be a really nice solution.

If you have a CD of all the distribution RPM files, you can generate a text database using the following:

rpm -qpil /mnt/cdrom/path-on-cd/RPMS/*rpm > rpms-data.txt 

Alternative Options

 

RPM MANIPULATION

All of these apps will convert rpm files to tar.gz files.

rpm2targz, rpm2tgz, rpm2cpio, alien, etc.

Extract a single file from rpm package without installing entire package

First use rpm -qpl <packagename>|grep <filename> to determine the path to which the file will be installed. Now use rpm2cpio

rpm2cpio <packagename> | cpio -ivd ./path/<filename>

The period will create the path and place <filename> within that structure under whatever directory you are currently in.

example:

find the dovecot init script in dovecot-0.99.14-1.1.el3.rf.i386.rpm)
rpm -qpl dovecot-0.99.14-1.1.el3.rf.i386.rpm  |grep init

(looks like the path is /etc/rc.d/init.d/dovecot)

rpm2cpio dovecot-0.99.14-1.1.el3.rf.i386.rpm | cpio -ivd ./etc/rc.d/init.d/dovecot

(created a ./etc/.... inside of the directory I am in: relative to pwd)

rpm2cpio turns an RPM into a standard CPIO archive that you can extract certain files from with the cpio command.

rpm2cpio package | cpio -iv --make-directories full-path

You may also convert the rpm to a cpio archive

rpm2cpio package > cpio-archive-file

If you want to remove a list of RPMs without typing each on separately, you can use the xargs command with rpm.

rpm -qa | grep xine

Install two RPM files at the same time. When you get errors because this requires that, yet that requires this, install them both at the same time. (failed dependencies)

rpm -Uvh php-5.2.2-1tr.i586.rpm php-pear-1.4.10-1tr.i586.rpm