05. RPM Package Manager

The one other major package manager we will discuss is RPM (RPM Package Manager), which was developed by Red Hat under the General Public License. RPM is used in several distros - RedHat, Fedora, SUSE/openSUSE, and Mandriva.

Package Naming Convention

RPM files have a more stringent convention than the packages found for Debian. You may find these packages at the RPM repository or simply through the yumdownloader command. In this lesson, we'll look at installing Ninvaders, space invaders for the command line!

Firstly, we want to install the package with the following command:

# yumdownloader ninvaders      

ninvaders-0.1.1-12.fc23.x86_64.rpm

Package Name
ninvaders
The name of the package.
Version Number
0.1.1
The version number.
Build Number
12.fc23
Minor changes made not by the package author but the package maintainer. These include small tweaks in configuration files or added documentations. Here, we can also see that this was the 12th build version, made for Fedora 23.
Architecture
x86_64
The package architecture. For example, i386 would signify the CPU's from 80386 onward. Here, we have the a x86_64 architecture.

The rpm command

rpm installs, verifies and queries RPM packages. Included are actions, along with options for fine-tuning. We'll look at the most well-used options, but for a more comprehensive list, check the man page.

# rpm [action][options] [package]

Below are some general options you can use with the rpm command.

General Options

-?|--help
Print a longer usage than normal.
--version
Print out the version number of rpm.
--quiet
Print as little as possible.

Now here are five of the most commonly used actions with rpm.

1) Querying

You can verify if a package is installed with the -q option. This will print out its name, version and release name.

# rpm -q ninvaders
package ninvaders is not installed# rpm -q openssh
openssh-7.1p1-3.fc23.x86_64

Here, we can see that openssh is already installed, while ninvaders is not.

If you already know that a program is installed, tack on the -i option to check its information.

# rpm -qi openssh
Name : openssh Version : 7.1p1 Release : 3.fc23 Architecture: x86_64 Install Date: Thu 29 Oct 2015 02:23:32 PM PDT Group : Applications/Internet Size : 1586400 License : BSD Signature : RSA/SHA256, Fri 25 Sep 2015 06:44:55 PM PDT, Key ID 32474cf834ec9cba Source RPM : openssh-7.1p1-3.fc23.src.rpm Build Date : Fri 25 Sep 2015 05:31:51 AM PDT Build Host : buildvm-14.phx2.fedoraproject.org Relocations : (not relocatable) Packager : Fedora Project Vendor : Fedora Project URL : http://www.openssh.com/portable.html Summary : An open source implementation of SSH protocol versions 1 and 2 Description : SSH (Secure SHell) is a program for logging into and executing commands on a remote machine. SSH is intended to replace rlogin and rsh, and to provide secure encrypted communications between two untrusted hosts over an insecure network. X11 connections and arbitrary TCP/IP ports can also be forwarded over the secure channel. OpenSSH is OpenBSD's version of the last free version of SSH, bringing it up to date in terms of security and features. This package includes the core files necessary for both the OpenSSH client and server. To make this package useful, you should also install openssh-clients, openssh-server, or both.

To list all packages listed in your system, use:

# rpm -qa
... libvisio-0.1.3-2.fc23.x86_64 libsysfs-2.1.0-18.fc23.x86_64 librdmacm-1.0.18.1-4.fc23.x86_64 spice-glib-0.30-1.fc23.x86_64 sssd-client-1.13.1-2.fc23.x86_64 ...

We can also query as to what dependencies a package fulfills.

# rpm -q --whatrequires openssh
openssh-clients-7.1p1-3.fc23.x86_64 openssh-askpass-7.1p1-3.fc23.x86_64 openssh-server-7.1p1-3.fc23.x86_64

2) Installing

To install a package, change into the directory that holds the .rpm file, then run with the -i option. With this, rpm will check for dependencies, conflicts, set config files, and unpack the files to place them in the right folders.

# rpm -ivh ninvaders-0.1.1-12.fc23.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
1:ninvaders-0.1.1-12.fc23          ################################# [100%]

The -i option does the actual installing, while the -v option is for verbosity, and -h is to display hash marks for progression.

To specify a root folder, you may add the --root dir option. This will specify where the root directory, which is helpful if you have more than one Linux installation.

When installing, you may run into dependency issues. To force the installation, use the --force option. To not check for dependencies, use --nodeps.

Now that we've installed ninvaders, we can play it by typing nInvaders!

3) Upgrading

To upgrade a package to its most recent version, use the -U option for upgrade (or install if unavailable) or -F for freshen.

# rpm -Uvh ninvaders-0.1.1-12.fc23.x86_64.rpm     

4) Uninstalling

To uninstall a package, specify the package name (not the .rpm) file.

# rpm -e ninvaders    

Configuration files

The RPM configuration file is located in /usr/lib/rpm/rpmrc. If you want to create your own settings, edit /etc/rpmrc or set a ~/.rpmrc file within your home folder.

Notably, this file allow you to fine-tune the compilation process, according to the CPU being used.

Just like how dpkg doesn't provide you with the ability to install and manage package dependencies, rpm does not either. Instead, we can use yum, which we will discuss next.

Want to avoid becoming a code monkey?

Clean Code

Want to avoid becoming a code monkey? Try Good Practice

Software expert Robert C. Martin presents a revolutionary paradigm with Clean Code: A Handbook of Agile Software Craftsmanship. Martin has teamed up with his colleagues from Object Mentor to distill their best agile practice of cleaning code "on the fly" into a book that will instill within you the values of a software craftsman and make you a better programmer.

$ Check price
49.9949.99Amazon 4.5 logo(427+ reviews)

More Good Practice resources

Take your Linux skills to the next level!

The Linux Command Line

Take your Linux skills to the next level! Try Linux & UNIX

The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell. Along the way you'll learn the timeless skills handed down by generations of gray-bearded, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more.

$ Check price
39.9539.95Amazon 4.5 logo(274+ reviews)

More Linux & UNIX resources

Ad