rpm has a -i (--install) option to install a package
rpm has a -U (--upgrade) option that will install or upgrade a package

The red hat documentation indicates that rpm -i is perfectly acceptable.

However every documentation I've ever seen has recommended using -U, even if the package is being installed for the first time.

Why is rpm -U commonly preferred over rpm -i ?


Most documentation suggests -U over -i because -i may fail if the package was already installed, or already had an earlier version installed; while -U will succeed even if "upgrading" from the package not being installed at all. When giving a how-to, as in the case of documentation, it's generally a better idea to give commands with a lower likelihood of a failure state.

| improve this answer | |

The documentation actually doesn't say -i should be used for upgrades. It says one should use it for kernel upgrades. The reason is, that should the system fail to boot with the new kernel, you still have the old kernel available. This however is a special case - kernel packages are pretty much orthogonal in the sense that they don't own conflicting files since everything is versioned (kernel, initrd and library modules from various kernel packages can live alongside each other).

Ordinary userspace packages are rarely this independent. Should you use rpm -i to perform an upgrade, you would likely end up with two packages of the same name (and different version) installed at the same time, with the earlier ones being broken (half overwritten). It is actually possible to install the same package twice - once that happens some tools and/or people are likely to get rather confused.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.