29

If I have an RPM located on a local disk -
what is the diffrefence between the following yum commands?

sudo yum install /tmp/rpm_name.rpm
sudo yum localinstall /tmp/rpm_name.rpm

Note:
I use RedHat/CentOS 7.

yagmoth555
  • 16,300
  • 4
  • 26
  • 48
boardrider
  • 889
  • 2
  • 15
  • 26

2 Answers2

32

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.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • 1
    In RHEL 6 and 7, what's the difference, if it wasn't simply an alias until 8? Is it that `localinstall` _only_ accepts paths until 8? – Lightness Races in Orbit Nov 20 '18 at 10:27
  • @LightnessRacesinOrbit Right, `localinstall` was the old code and only accepts local paths through RHEL 7. In 8, the old code is gone and `localinstall` is simply `install`. – Michael Hampton Nov 20 '18 at 13:07
5

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

Sentient
  • 151
  • 1
  • 3