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?
Try: rpm -iv --replacepkgs <packagefile>.
More details are in the book.