What is the difference between the -i and -U options used in rpm command in Linux

RPMs can be installed from the command line like the following:

# rpm -Uvh [package-name]-[version].rpm

or

# rpm -ivh [package-name]-[version].rpm

Option -U is for upgrade operation that means installing a new version of a package and removing all previous versions of the same package and also removing obsoleted packages. If you have not installed a package previously, the upgrade operation will install the package.

Option -i is for install operation. It used for installing a package for the first time. It doesn’t remove any package so it can be also used for installing multiple versions of a package. If you use -i and an older version of a package is already installed then after the successful installation of a newer version, both versions of a package will be installed in the system at the same time, the older version won’t be removed. But many packages don’t allow to have installed more versions at the same time and during installation of different versions of the same package conflicts often occurs. One exception is a kernel package that can be installed in more versions.

Recommendations on using option -i and -U

It is recommended to use the option “-i” instead of “-U” for installing a new version of the kernel. If you use “-i” then an old version of kernel stays in the system and if the new version of the kernel doesn’t work then you can return to the old version.

So you should almost always use -U for installing and updating packages. The special case when you should use -i is e.g. kernel package. Additional information is available by typing man rpm at the command line.

# man rpm
Related Post