by pbharris
Updated October 5, 2002

(Transferred from the wiki by Peter)

RPM (Redat Package Manger) is the most common and and one of the best package managers out there. There are some nice GUI tools, but these really lack the details that some people may need. That is where this RPM Cheat comes in. Here are some usefull commands for working with RPMs at the command line.

rpm -ivh packagename.rpm
This simply installs a package.

rpm -Uvh packagename.rpm

This simply upgrades a package or install a package fresh, please note that the U is a capitol U.

rpm -qi packagename
This give you the descrption of the package, e.g. rpm -qi mozilla

rpm -qp packagename.rpm

This simply querys a package to determine its version number. You can add an i after the qp to get a more thorough descrption.

rpm -qpl packagename.rpm

This querys a package to determine its version number and lists all the files that would be installed and where they would go. The package does not need to be installed already to use this.

rpm -e packagename

This removes (i.e. uninstalls) a package. Another thing to note is that the rpm suffix is not used

rpm -q packagename

Tells the version of packagename. Note is that the rpm suffix is not used for this command either.

rpm -ql packagename

This lists all files install by package packagename. Note is that the rpm suffix is not used for this command either.

rpm -qf

filename This tells which package a file is a member of. For example rpm -qf /usr/bin/mozilla will tell you that this file is included with the package mozilla.

rpm -qa
list all installed RPM packages on you system. An useful trick is to have this piped into a grep to search for something you havea rough idea of on how to spell e.g. rpm -qa | grep calc to look for all packages whcih have the word calc in them.

For RPM versions 4.0.x or earlier use these commands for building your own RPMs. rpm --rebuild package.src.rpm Builds an RPM for your system when you don't have or can't find a binary. for example: rpm --rebuild fvwm2-2.2.3.src.rpm. The built RPM will be placed in /usr/src/<distroname>/RPMS/i386/ by default, e.g. for Red Hat it will be in /usr/src/redhat/RPMS/i386/.

rpm --rebuild --target [arch] packagename.src.rpm
Builds an RPM for a specific architecture which can be nice for CPU optimizations. An example: rpm --rebuild --target athlon galeon-1.0.2.src.rpm . The RPM will be placed in /usr/src/<distroname>/RPMS/<architecture>, e.g. /usr/src/redhat/RPMS/athlon/

For RPM versions 4.1 or higher use these commands for building your own RPMs.

rpmbuild --rebuild package.src.rpm

Builds an RPM for your system when you don't have or can't find a binary. for example: rpm --rebuild fvwm2-8.1.src.rpm. The built RPM will be placed in /usr/src/<distroname>/RPMS/i386/ by default, e.g. for Red Hat it will be in /usr/src/redhat/RPMS/i386/.

rpmbuild --rebuild --target [arch] packagename.src.rpm

Builds an RPM for a specific architecture which can be nice for CPU optimizations. An example: rpm --rebuild --target athlon galeon-1.0.2.src.rpm . The RPM will be placed in /usr/src/<distroname>/RPMS/<architecture>, e.g. /usr/src/redhat/RPMS/athlon/

rpm -Uvh --force packagename.rpm Like it says - it forces an upgrade and/or install. Use at your own risk.

rpm -Uvh --nodeps packagename.rpm Have it ignore dependcy errors. This can be handy when you have one package you know is installed but RPM does not have it in its database.
If you have any questions or additions please feel free to email me at pbharris_359@yahoo.com or send me a private message here at OpenFree.

Niether I nor is OpenFree is responsible for any problems or damage you may cause you system by using these commands.