Installing software from RPM packages

Last Updated on May 6, 2019

Learn how to install software from RPM packages in Linux. You’ll also learn how to upgrade, remove and administer the RPM packages on your system.

What is RPM >

RPM stands for Red Hat Package Manager. However, these days RPM isn’t only Red Hat specific because many other Linux distros use RPM for managing their software. For example, both Mandriva and SuSE use RPM for software management. With RPM, you can install, upgrade and uninstall software on Linux, as well as keep track of already installed RPM packages on your system. This can be done because RPM keeps a database of all software that was installed with it.

RPM uses software packages that have (surprise) the .rpm extension. An RPM package contains the actual software that gets installed, maybe some additional files for the software, information on where the software and its files get installed, and a list of other files you need to have on your system in order to run this specific piece of software.

When you use RPM for installing the software package, RPM checks if your system is suitable for the software the RPM package contains, figures out where to install the files the package provides, installs them on your system, and adds that piece of software into its database of installed RPM packages.

Note that different Linux distros may keep their software and the files related to that software in different directories. That’s why it’s important to use the RPM package that was made for your distribution. For example, if you install a SuSE specific software package on a Red Hat system, RPM may put the files from that package into wrong directories. In the worst case the result is that the program doesn’t find all the files it needs and doesn’t work properly.

There are some good graphical programs for installing RPM packages, but in this tuXfile I’ll discuss the fool-proof command line method for installing software. Note that you need to be root when installing software in Linux. When you’ve got the root privileges, you use the rpm command with appropriate options to manage your RPM software packages.

Installing and upgrading RPM packages >

For installing a software package, you use the rpm command with -i option (which stands for “install”). For example, to install an RPM package called software-2.3.4.rpm:
rpm -i software-2.3.4.rpm

If you already have some version installed on your system and want to upgrade it to the new version, you use -U option instead (which stands for “upgrade”). For example, if you have software-2.3.3.rpm installed and want to upgrade it:
rpm -U software-2.3.4.rpm

If all goes well, the files in your package will get installed into your system and you can happily run your new program. But where is your new program? Note that rpm doesn’t usually create a special directory for the software package’s files. Instead, the different files from the package get placed into appropriate existing directories on your Linux system. Executable programs go usually into /bin, /usr/bin, /usr/X11/bin, or /usr/X11R6/bin after installing with rpm.

But how can you run your new program if you don’t know where the executable is? Sometimes the program gets automatically added into your menu, but usually you can just run the program by typing its name at the command prompt. In most cases you don’t have to know where the program was installed because you don’t have to type the whole path when running the program, only the program’s name is needed.

Error: failed dependencies >

Issuing rpm -i or rpm -U installs the software and you can start using it. RPM is very easy when it works. However, RPM can be a devil when it doesn’t work. There are many reasons why installing software goes wrong, but usually it’s because of failed dependencies.

You see, many Linux programs need other files or programs in order to work properly. In other words, a certain piece of software depends on other software. When you try to install an RPM package, RPM automatically checks its database for other files that the software being installed needs. If RPM can’t find those files in its database, it stops installing the software and complains about failed dependencies.

When you get a dependency error, RPM spits out a list of files the program needs. Take a look at the list. The files in the list are probably ones you don’t have on your system, or files you have but are wrong versions. When you get the dreaded dependency error, you’ll have to find the files RPM complains about, install or upgrade those files first, and then try to install the package you were installing in the first place.

However, sometimes RPM is just plain stupid. You see, only software that was installed with RPM gets added into the database of installed software. This means that if you’ve used some other method for installing a certain program, RPM doesn’t know the program exists on your system. In this case RPM complains about failed dependencies even when the needed program does exist on your system and there are no failed dependencies!

If you know the needed files are there and RPM is just being stupid, you can ignore the dependencies. Use the --nodeps option if you want to tell RPM not to check any dependencies before installing the package:
rpm -i software-2.3.4.rpm --nodeps

This forces RPM to ignore dependency errors and install software anyway, but note that if the needed files are missing anyway, the program won’t work well or won’t work at all. Use the --nodeps option only when you know what you’re doing or when you’re bone-headed enough 😉

Removing software installed with RPM >

To remove software that was installed with RPM, you use the -e option (which stands for “erase”):
rpm -e software-2.3.4

Note that when installing software, you have to type the name of the RPM package. But when removing software, you don’t have to type the whole name of the package that contained the software. You don’t have to type the .rpm extension when removing software. Probably you don’t have to type the version number, either, so this would do exactly the same as the above:
rpm -e software

This rpm -e command uses the RPM database to check where all the files related to this software were installed and then automatically removes all of those files. After removing the program files, it also removes the program from the database of installed software.

This is why it’s so important you NEVER remove RPM software manually (for example, deleting single files with rm). If you just run around your system randomly deleting files that were installed with RPM, you’ll get rid of the software but RPM doesn’t know it and doesn’t remove the software package from its database. The result is that RPM still thinks the program is installed on your system, and you may run into dependency problems later.

If you used RPM for installing a certain piece of software, use RPM for removing that piece of software, too!

Querying the RPM database >

As you already know, the RPM database contains a list of all installed RPM packages on your system. You can query this database to get info of the packages on your Linux system. To query a single package, you use the -q option. For example, to query a package whose name is “software”:
rpm -q software

After issuing this command, rpm either tells you the version of the package, or that the package isn’t installed.

If you want a list of all packages installed on your system, you’ll have to query all with -qa:
rpm -qa

Most likely this list will be very long, so you’ll need a way to scroll it. The best way is to pipe the list to less:
rpm -qa | less

If you’re looking for packages whose names contain a specific word, you can use grep for finding those packages. For example, to get a list of all installed RPM packages whose names contain the word “kde”, you could do something like this:
rpm -qa | grep kde

The above command makes rpm list all packages in its database and pass the list to grep. Then grep checks every line for “kde” and finally shows you all the lines that contain the word “kde”.

If you have no idea what is grep or piping, take a look at the Redirecting standard input and output tuXfile.