• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to install an RPM package into a different directory in CentOS/RHEL/Fedora

by admin

Identifying Relocatable Package

Not all RPM packages can be installed into another directory. An RPM package that can be installed into a different directory is said to be relocatable. To check whether a particular package is relocatable, use the command:

# rpm -qpi [rpm package] | head -1

For example, the packages: redhat-lsb-1.3-3.1.EL3.i386.rpm and rsync-2.5.7-5.3E.i386.rpm produces below output:

# rpm -qpi redhat-lsb-1.3-3.1.EL3.i386.rpm | head -1
Name        : redhat-lsb                   Relocations: (not relocatable)
# rpm -qpi rsync-2.5.7-5.3E.i386.rpm | head -1
Name        : rsync                        Relocations: /usr

It states that the redhat-lsb package is not relocatable but rsync is.

Relocating an RPM package

1. Relocating an rpm package allows user to install the rpm package to a different directory than the default. That means you may install the rsync package into a different directory, say /opt using the rpm option –prefix like this:

rpm -ivh --prefix=/opt rsync-2.5.7-5.3E.i386.rpm

2. To verify whether it was indeed installed in /opt, use the command rpm -ql rsync. Below is a sample output:

# rpm -ql rsync
/etc/xinetd.d/rsync
/opt/bin/rsync
/opt/share/doc/rsync-2.5.7
/opt/share/doc/rsync-2.5.7/COPYING
/opt/share/doc/rsync-2.5.7/README
/opt/share/doc/rsync-2.5.7/tech_report.tex
/opt/share/man/man1/rsync.1.gz
/opt/share/man/man5/rsyncd.conf.5.gz

3. Now, if the similar process is applied to the redhat-lsb package, this error message will appear:

# rpm -ivh --prefix=/opt redhat-lsb-1.3-3.1.EL3.i386.rpm
error: package redhat-lsb is not relocatable

Final Thoughts

Relocation of packages listed as not relocatable is unsupported by most of the OS vendors like RedHat. Therefore it is advisable to only relocate “relocatable” rpm packages.

Filed Under: CentOS/RHEL 5, CentOS/RHEL 6, CentOS/RHEL 7, CentOS/RHEL 8, Fedora, Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL 5 : How to disable device mapper multipath (dm-multipath)
  2. manpath Command Examples in Linux
  3. calcurse Command Examples in Linux
  4. How to Disable VNC Server from Xinetd in CentOS/RHEL 7
  5. GlusterFS – Real Time Data Replication Across Multiple RHEL/CentOS Nodes
  6. Comparing NET-TOOLS V/s IPROUTE Package Commands (ip Vs ifconfig command comparison)
  7. How to configure the logging of failed login attempts for vsftpd
  8. pw-cat Command Examples in Linux
  9. “Bad id for repo: My Repo, byte = 2” yum update error
  10. ‘docker images’ command error – “Permission Denied”

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright