What's the difference between `yum install <local path>` and `yum localinstall <local path>`

Solution 1:

In RHEL 5 and previous versions, yum install only accepted package names from enabled repositories, and did not accept paths to local RPMs; you had to use yum localinstall to install these.

In RHEL 6 and later, yum install accepts both package names and local filenames, so localinstall is no longer necesary, but it's included for backward compatibility.

In RHEL 8, dnf localinstall is simply an alias for dnf install.

Solution 2:

Note that in CentOS7 there is a subtle difference

sudo yum install <alreadyExistingPackage>

will give an error Error: Nothing to do

but the

sudo yum localinstall <alreadyExistingPackage>

will not give an error

If you run your script with -e option

#!/bin/bash -e

you will notice this difference