The difference between ‘rpm -Uvh’ and ‘rpm -ivh’ (or how to install packages in RHEL, CentOS or Fedora)

When installing packages in RHEL, CentOS, or Fedora, chances are you use yum, the default package manager. But what if you want to download a package not provided in a repository? Or what if you just want to upgrade a package to the latest version and your repositories haven’t upgraded it yet?

Most users know that to install a package from an RPM, you simply use the rpm command. But a bit of perusing on the internet will show that people use various flags when installing packages:

  • rpm -i
  • rpm -ivh
  • rpm -U
  • rpm -Uvh

In this post we’ll examine the difference and whether or not you should care.

The simple truth is that the only flags that are truly important to most users are -i and -U.

Using -i

When using -i you tell the rpm package manager to install the package. For example to install htop version 0.8.3:

# rpm -i htop-0.8.3-1.el5.rf.x86_64.rpm

This command only installs htop version 0.8.3. It does not care if you have other versions of htop installed. If you do not have any other versions of htop installed this is probably the correct command to use. If you do have other versions of htop installed, this is probably NOT what you want to do.

Using -U

When using -U you tell the rpm package manager to upgrade the package. For example to upgrade htop to version 0.9:

# rpm -U htop-0.9-1.el5.rf.x86_64.rpm

This command not only installs htop version 0.9, but also removes any other versions of htop that are installed. The great thing about using -U is that even if you don’t have other versions of the software installed, it will still install the version you requested. In this way you can think of -U as a more careful version of -i. In nearly every practical case you want to use -U!

But what about -v and -h?

The -v and -h flags are just to print more verbose information regarding the installation or upgrade. These are optional, but useful parameters. Below is the information from the man page:

-v Print verbose information - normally routine progress messages will be displayed.
-h, --hash Print 50 hash marks as the package archive is unpacked. Use with -v|--verbose for a nicer display.

How can I learn more about rpm?

If you want to learn how to use other features of rpm, I would suggest using the man page by typing this at terminal:

# man rpm

Man pages aren’t nearly as scary as people make them out to be. They provide plenty of helpful information and they’re always the first place to turn when looking for help with a command.

In conclusion, any good admin should understand every command he or she uses at least in some detail. But for the common case, rpm -U or rpm -Uvh should serve you well.

Copyright Tech 2017