51

I have installed a package from .rpm file and it is stored in /opt.

After some configuration I found that I need to reinstall the software. So I deleted the directory and attempted to reinstall the file with rpm -i XXX.rpm. But it tells me that package xxx is already installed.

How can I reinstall it?

Piotr Dobrogost
  • 41,292
  • 40
  • 236
  • 366
Newbie
  • 2,775
  • 6
  • 33
  • 40
  • 4
    Learn from this lesson :) use `rpm(8)` to uninstall packages in the future. Get friendly with the `--force` options... – sarnold May 25 '11 at 04:29
  • I learnt. haha :D..thanks! BTW could you tell me the command. is it rpm --force XXX.rpm? it doesn't seem working – Newbie May 25 '11 at 04:37
  • 1
    @Newbie You got to tell the program *what* you want to force. `--force` gets applied additionally. – glglgl Feb 02 '14 at 10:01

4 Answers4

81

Try: rpm -iv --replacepkgs <packagefile>.

More details are in the book.

villapx
  • 1,743
  • 1
  • 15
  • 31
sarnold
  • 102,305
  • 22
  • 181
  • 238
18

You could also hit:

rpm -ivh --force [yourpackage.rpm]

which safely overwrites the old installed package with the desired new package. Furthermore, if you wish to install and upgrade simultaneously, then this next option:

rpm -Uvh [yourpackage.rpm]

will enable you to install including any upgrade simultaneously.

Another extra tip: You may face an error situation where an upgrade depends on another which in turn depends on another and inturn also depend on the one you want to install thus causing a "dependency upgrade loop". To avoid that hit:

rpm -Uvh --nodeps [yourpackage.rpm].
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Laenka-Oss
  • 939
  • 2
  • 17
  • 25
  • rpm -ivh --force [yourpackage.rpm] is the best solution for reinstalling an RPM package – jose miguel rivera rodríguez Dec 17 '19 at 00:27
  • Telling the OP who could not install a package because it had already been installed to use `--force` instead of `--replacepkgs` (as suggested in the already accepted answer) is wrong because `--force` *(...) adds --replacepkgs and --replacefiles to the command.* (http://ftp.rpm.org/max-rpm/s1-rpm-install-additional-options.html) so using it might lead to overwriting files installed as part of unrelated package. Using `--replacepkgs` is safer and should be enough in this situation. – Piotr Dobrogost Jul 23 '20 at 15:10
9

Starting with version 4.12.0 there's --reinstall option.

From RPM 4.12.0 Release Notes:

New --reinstall mode which can handle changing file policies (RhBug:966715)

From man rpm:

rpm {--reinstall} [install-options] PACKAGE_FILE ...

This reinstalls a previously installed package.

Piotr Dobrogost
  • 41,292
  • 40
  • 236
  • 366
1

You got to uninstall the software's rpm:

rpm -e XXX.rpm

Then install it :

rpm -i XXX.rpm

Next time whenever you are not sure about the software being already there on the machine, always check using:

rpm -qa |grep XXX 

where XXX is the software name or part of the name. This will give you the version already present on the machine.

mohanjot
  • 1,490
  • 2
  • 11
  • 15