Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
Site Navigation
Linux Forums
Linux Articles
Product Showcase
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Free Publications

I was in doubt about writing this article. There are several tutorials covering this topic but I want to try to write a simple article that shows the basis of rpm usage. So this is not an advanced tutorial but a document for the impatient and the people that performs simple operations with rpm.

RPM, the history

RPM is an acronym for Red Hat Package Manger. As the name said, it was developed by Red Hat, but nowadays it is used by many other distributions. In fact, RPM is part of the Linux Standard Base, an attempt of standardization in the Linux world. RPM can run under several platforms like AmigaOS, BeOS, Solaris and others.

There are other package managers. Debian uses .deb packages and Gentoo uses the portage, a clone of the FreeBSD ports collection. The last one is especially efficient when installing software from source code. And the .pbi attempt from the PC-BSD project is another interesting approach specially to solve the problem with dependencies.

It is possible that RPM is not the best package manager in the world (I hope nobody from Red Hat is reading this...) but it can be as efficient and easy as some of the above.

Why should you use RPM?

You are not obligated to install software from rpm packages in any way. However, there are some benefits you should know:

  • RPM can install, uninstall and upgrade software easy and fast.
  • RPM keeps track of the packages, versions and files installed in your system.
  • RPM can build software from sources and generate a specific package for your system with the optimizations that you need.
  • Queries about your packages (installed or not).
  • RPM creates a central database to achieve these objectives. So if you use RPM in your rpm-based distribution, you are working for consistency and stability. Since RPM is widely used in the Linux world, is rare that you can’t find a rpm package for the software that you want. Before you install software from a source tarball I recommend you to look for the equivalent rpm package. See references at the end of the article.

    RPM packages

    RPM packages often contains applications. This means that a rpm package contains the software needed for an application to run (except dependencies). Other times, a package can contains documents e.g: help files or configuration files.

    RPM packages can be signed. This is useful to verify the identity of the packager, so you can download and install from a official site or a trusted ftp server.

    An RPM package uses the .rpm extension. Usually an rpm package begins with the name of the package, followed by the version, then it is possible to find an acronym for the distribution the package come from, then the architecture it has been compiled for (or source if it is the case) and the .rpm extension e.g :


    The same package with .src, identifies a source code package.


    The first one shows the mplayer application, version 1.0-1.pre7.12.2.20060. The package comes from Mandriva distribution and it is compiled for x86_64 architecture (AMD 64 and Opteron)

    Other acronyms you can see are:

    FC Fedora Core
    EL Red Hat Enterprise Linux
    Yd Yellow Dog
    CL Conectiva Linux (now merged with Mandrake)
    ASP ASP Linux

    And other architectures that you can find are:

    i386 Intel 386
    i486 Intel 486
    i586 Intel 586
    i686 Intel 686
    x86_64 AMD 64 bits processors (AMD 64, Opteron)
    ppc Power PC
    noarch Platform-independent package

    Although rpm packages can work across different platforms, I suggest that you try to choose the package specifically made for your distribution to avoid problems or conflicts. Of course, don’t try to install a x86_64 package in a Pentium 4 ;)

    Using RPM

    Now I explain the most common commands to perform basic operations with RPM.

    Installing software (rpm -i)

    Install software from a rpm package is easy, just type:

    rpm -ivh package.rpm

    for example:

    rpm -ivh lkmonitor-0.1-1.x86_64.rpm

    If everything is ok, you will see a progress bar while installing the software. The –v and –h option activate the verbose and human mode.

    With rpm you can install more than one file at a time, just type the names of the packages separated by spaces:

    rpm -ivh lkmonitor-0.1-1.x86_64.rpm ipw2200-firmware-2.4-2.0.rf.noarch.rpm

    If you are familiar with installing software from sources, you will know the - - prefix option that allows a package to be installed in a specific location. RPM also provides this option, so you can type:

    rpm -ivh - -prefix /home/fernape/my_software lkmonitor-0.1-1.x86_64.rpm

    This option will be only available with packages marked as Relocatable

    One of the goals of RPM (I think) is that you can install and update software not only from files that you have in your hard disk. You can specify also an URL to install from e.g:

    rpm -i ftp://rpmfind.net/Linux/sourceforge/r/ru/rusxmms/xmms-1.2.10-csa27.3.i586.rpm
    rpm -i http://www.xmms.org/files/1.2.x/rpm/fc1/xmms-1.2.10-1.i386.rpm

    Sometimes you can find problems with dependencies, i.e. packages that are needed to be installed, before the new package can be also installed. If this is the case, you should install this packages first. Dependencies are the origin of long head aches.

    Uninstalling software (rpm -e)

    To uninstall the package below, type:

    rpm -e lkmonitor-0.1-1

    You don’t need the architecture or the .rpm to uninstall the package. As we said before, you can specify more than one package name to uninstall.

    Updating packages (rpm -U)

    Updating packages means that rpm should uninstall the previous version and install a newer one. So as you can imagine, you could do this by hand… Well, really it is not true in some cases. If you try to uninstall an older package it is possible that you get an error like this:

     error: Failed dependencies:
    glibc-common = 2.3.4-2.13 is needed by (installed) glibc-2.3.4-2.13.x86_64
    glibc-common = 2.3.4-2.13 is needed by (installed) glibc-2.3.4-2.13.i686
    /usr/bin/gencat is needed by (installed) whitebox-lsb-1.3-5.2.WB1.x86_64
    /usr/bin/getconf is needed by (installed) whitebox-lsb-1.3-5.2.WB1.x86_64
    /usr/bin/getent is needed by (installed) stunnel-4.05-3.x86_64
    /usr/bin/iconv is needed by (installed) whitebox-lsb-1.3-5.2.WB1.x86_64
    /usr/bin/locale is needed by (installed) whitebox-lsb-1.3-5.2.WB1.x86_64
    /usr/bin/localedef is needed by (installed) whitebox-lsb-1.3-5.2.WB1.x86_64

    This shows some conflicts because the package attempted to be removed is needed by other installed components.

    What –U flag does is to uninstall and install the new package avoiding this annoying messages. It is also usual to install packages with –U flag in this way:

    rpm -Uvh lkmonitor-0.1-1.x86_64.rpm

    This line will update lkmonitor package and if it does not exists, it will be installed for the first time.

    Verifying packages (rpm -V)

    This option is very useful to check if every package in your system remains properly installed. This option checks a lot of parameters such as owners, MD5 sum, sizes, etc. Since this is an introduction for newbies I don't say more. If you want to learn more about this option try man rpm and if you want to verify every package in your system, type:

    rpm -Va

    but notice that this can take a while.

    Testing operations (--test)

    Sometimes, you could think that the effect produced by an install or upgrade operation could be dangerous. So it would be great if you could emulate the operation while actually it is not really done at all. The - -test flag makes all the operations for the install or upgrade but it doesn’t touch any of your files:

    [fernape@Hammer ~]$ rpm -ivh --test livna-release4.rpm
    error: Failed dependencies:
    fedora-release >= 4 is needed by livna-release-4-0.lvn.7.4.noarch

    Querying RPM database (rpm –q)

    We have talked about installing, upgrading and removing packages. But why do we do this? The answer is to keep our files and packages (and our system, too) under control. So it is usual that you want to know which version of some program you have installed.

    [fernape@Hammer ~]$ rpm -q vsftpd

    If you want more information, you can type:

    [fernape@Hammer ~]$ rpm -qil vsftpd
    Name : vsftpd Relocations: (not relocatable)
    Version : 2.0.1 Vendor: whiteboxlinux.org
    Release : 5 Build Date: mar 03 may 2005 23:30:13 CEST
    Install Date: vie 27 may 2005 18:09:45 CEST Build Host: bob
    Group : Entorno de Sistema/Demonios Source RPM: vsftpd-2.0.1-5.src.rpm
    Size : 262809 License: GPL
    Signature : DSA/SHA1, mié 04 may 2005 04:54:25 CEST, Key ID ae52a76d73307de6
    URL : http://vsftpd.beasts.org/
    Summary : vsftpd - Demonio Ftp muy seguro
    Description :
    vsftpd es un demonio FTP muy seguro. Ha sido escrito completamente a partir
    de un borrador.

    The first block of information is because the -i flag and the list of files that has been truncated is caused by the -l flag.

    This is used for packages installed and registered in the RPM database. If you want to gather information from a package not yet installed, you also need the –p (package) option:

    [fernape@Hammer]# rpm -qilp gnome-cpufreq-applet-0.3.1-2.x86_64.rpm
    Name : gnome-cpufreq-applet Relocations: (not relocatable)
    Version : 0.3.1 Vendor: (none)
    Release : 2 Build Date: dom 20 feb 2005 18:31:52 CET
    Install Date: (not installed) Build Host: extras64.linux.duke.edu
    Group : User Interface/Desktops Source RPM: gnome-cpufreq-applet-0.3.1-2.src.rpm
    Size : 220568 License: GPL
    Signature : DSA/SHA1, dom 20 feb 2005 21:54:01 CET, Key ID 82ed95041ac70ce6
    URL : http://linups.org/~kal/gnome-cpufreq-applet/
    Summary : CPU frequency scaling monitor applet
    Description :
    GNOME CPUFreq Applet is a CPU Frequency Scaling Monitor for GNOME Panel.
    [list of files truncated]

    This will show a full report for the package specified. It is also possible to show only a subset of this information. Try with –c or –l flags.

    Often, you will want to list all your installed packages. To do this, type:

    rpm –qa

    This will display a very long list, so it is a good idea to filter the output through a less or more command:

    rpm –qa | less

    It is also possible that you know that some time ago, you installed a certain package, but… you can’t remember the full name. You can follow two strategies:

    Filter the output with grep:

    [fernape@Hammer ~]$ rpm -qa|grep cpufreq

    Or you can use wildcards when searching for packages:

    [fernape@Hammer ~]$ rpm -qa "*terminal*"

    I think the second approach is faster because it doesn’t need to create and communicate two processes.

    One of the most important features of RPM is that you can search which package installed a specific file. For example:

    [fernape@Hammer ~]$ rpm -qf /bin/ls

    Installing from sources

    When you get an .src.rpm package, you have got the sources for a specific application. This .src.rpm package often contains the scripts needed to rebuild a new package.

    The process of rebuilding a package is the following:

    • First, the .src.rpm is unpacked and the sources are placed in certain well-known directories.
    • The preparation scripts are executed (usually a configure script)
    • The software is compiled with the preferences setting from your rpmrc file.
    • The compiled software is packed again and it is ready to be installed.

    To rebuild an .src.rpm package use the rpmbuild command in this way:

    rpmbuild --rebuild gnome-terminal-2.7.3-2.src.rpm

    This will generate a long output in the screen. If you see the commands executed, you can keep track of the operations performed (unpacking, configuration of the sources, compiling…)

    Because of rebuilding source packages implies the software compilation, it is possible that you find some problems like missing libraries or compiling errors (this is not usual, but it could occur). If this shows no errors, you will find your package in a directory similar to this:


    The “whitebox” subdirectory comes from the name of the distribution I use (it can be “Red Hat”, for example) and the last directory specifies your architecture (this can be “i386” ,for example).

    The rpmrc file

    The rpmrc file keeps your preferences for rebuilding packages. Is in this file where you should change things like the default target platform or the gcc optimization options. This article does not cover all the options in rpmrc file, but the most useful lines you could change are:

    • optflags: used to specify options to be passed to the C compiler.
    • buildarchtranslate: change this if, for example, you have an athlon machine and your rebuildings operations generate i386 packages.

    Some advices

    The best way to learn more about using rpm is to practice with it, so I recommend you:

    • Install some little packages (like panel applets and not complex applications)
    • Try to remove them
    • Install an old version and then try to update with -U
    • Move some file from its original location to another one. Then run rpm with th -V flag and analyze the output.
    • Use always trivial packages. Do not make test with core packages like glibc, components of the GNOME or KDE desktop, etc.


    You can find many rpm packages at:

    http://rpmfind.net (the firs site you should visit)
    http://rpm.pbone.net/ (a lot of packages for many distributions)
    http://dag.wieers.com/home-made/apt/ (I think this is really good and so I use it)
    http://freshrpms.net/ (a lot of packages for Fedora, Red Hat, Yellow Dog, etc)
    http://rpm.livna.org/ (packages for Fedora systems not included in the official releases)

    If you are looking for more information, you can visit these links: http://www.rpm.org/max-rpm/ (this is six years old, but it is still the main reference)
    http://www.rpm.org/ (the official site)
    http://fedora.redhat.com/docs/drafts/rpm-guide-en/ (good and actual guide)

Rate This Article: poorexcellent
Comments about this article
Updating rpm packages
writen by: Jeff Largent on 2006-05-09 08:00:50
In the section "Some advises" you talk about updating an rpm with the -U, I would recommend using a -F. The difference is with the -U if the package does not exist on the system it will be installed, with the -F it skips that package. That can be an important difference when you are working with several systems and doing scripted upgrades. All of the rpms can be in a nfs share and then it is just a matter of sshing to each system and running "rpm -F /nfs/share/rpms/*".
RE: Updating rpm packages written by Jeff Largent:
rpm installation
writen by: michael on 2006-05-17 17:48:00
I am a complete newbie and am trying to install some rpm software from a dvd. This DVD is Open Suse 10 rpm package and not the Suse 10 installation dvd. There are three problems that prevent me from installing any package from the dvd. First, I tried to use Yast GUI from installation source by installing the Open Suse dvd to the hard drive and then trying to install a file. I wasn't clear what directory this dvd was automatically installed into, but no matter what string I used (-Uvh, -f -i)to install a file, nothing was recognised. Second. I then went into the file directly from the dvd and received a notice for Yast to install it. This file was Limewire and when Yast tried to install it, there was a conflict of dependencies.This dependency said that jr2e was not installed. I checked the /etc file and it was installed? (Though jr2e was also on the Open Suse dvd)Third. I then tried to install the file directly from a terminal with the dvd in my cdrom drive by using a string such as rpm /media/dvd open suse 10 i586 rpm -Uvh limewirelinux rpm or a variation of that string. Nothing was recognised? A fourth problem is that, when using the Yast2 GUI to install software from installation source, the drop down dialogue box simply begins the process when a souce is chosen (in this case a dvd), yet the help files on the left ask you to specify a path? Perhaps I am confused or have just made a hash of it. Are able to clarify for me exactly where I have gone wrong and how to install a file from a dvd? Thanks Michael
RE: rpm installation written by michael:
how do I run a script only when the -U w
writen by: shooali on 2006-06-15 13:06:21
Hello, I would like to run a command only when upgrading my RPM, how do I determine from withing the rpm spec file weather the -U switch was used? Thanks,
RE: how do I run a script only when the -U w written by shooali:
writen by: elizalde on 2006-07-02 22:35:59
This is the best article I've read about RPM. Thank a alot Sir Fernando..
RE: Wow! written by elizalde:
IBM Software Engineer
writen by: Abdul Islam on 2006-11-16 18:50:09
"This site does a great job explaining RPMs as well as teaching you how to use them." Thanks
RE: IBM Software Engineer written by Abdul Islam:
dependency hell
writen by: al on 2007-02-02 09:27:23
Good explanations. I am somewhat confused by the fact that I qam trying to use -U but it still refuses to upgrade. # rpm -fUvh --replacepkgs db-4.3.27-3.i586.rpm error: Failed dependencies: libdb-4.2.so is needed by (installed) iproute2-2.4.7-866.11 Can anyone assist please?
RE: dependency hell written by al:
writen by: damarlin on 2007-02-02 15:42:41
RE: developer written by damarlin:
dependency hell
writen by: dependecy hell on 2007-02-05 03:51:11
Thanks fot that. It the only logical conclusion. However, this quote comes from the article itself : What –U flag does is to uninstall and install the new package avoiding this annoying messages. It is also usual to install packages with –U flag in this way: This says that using the -U flag avoids the error dependency messages that I see. Since this is not the case I can only assume that the article is flawed. I could understand if what I was trying to install was dependent on something that was not already installed but this is not the case. Since I am seeing about 50 dependency messages for the packages that I want to install I guess I should stop typing and get to work!!
RE: dependency hell written by dependecy hell:
writen by: fares on 2007-06-30 04:33:15
thnx a lot for this topic. it is rare to find such easy guide... I wish you can give us more topics like that.
RE: wonderfull written by fares:
AIX Compatible
writen by: Jino on 2007-08-06 12:25:14
I have an existing rpm package designed to install on RedHat and SuSE. The build environment used is RedHat Enterprise. Now I have a requirement to support AIX systems as well and was wondering what I need to do to generate the rpm package for AIX built on our existing build environment(RedHat)? Any setting or declaration I need to pass so it would allow to install on AIX? Thanks in advance.
RE: AIX Compatible written by Jino:
Don't forget to update
writen by: Peter on 2008-03-20 21:00:57
A good article on RPM methods, I myself prefer package management via APT. Something to remember for your servers and package management is the update process. Many forget about this as historically Linux has not been as susceptible to worm's as Windows but keep in mind that your distribution should be updated on a regular basis. Using APT or RPM or other tool - dont only use these tools to add new packages use them to keep your security patches up to date. You can even add a cron job so that it happens automatically when you sleep -- not recommended for critical production systems but perfect for your home Linux gateway. A quick Nessus scan is also something to keep in mind to ensure your listening services are up to date and secure. Regards, Peter online security scans [url=http://www.hackertarget.com]hackertarget.com[/url]
RE: Don't forget to update written by Peter:
rpm -qa not working
writen by: Subhanjan on 2008-11-04 01:14:30
Hi All, I have a Linux box RHEL4u6 where I am unable to execute rpm -qa but I am able to install the packages using -ivh.I have tried rebulding the database by rpm --rebuilddb it didnt worked. Please Help me. With Regards. Subhanjan
RE: rpm -qa not working written by Subhanjan:
vc wowgold
writen by: buywowgold on 2008-12-03 23:39:29
RE: vc wowgold written by buywowgold:

Comment title: * please do not put your response text here