• 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. How to Control user access to Virtual Machine in RedHat Virtualization
  2. CentOS / RHEL 7 : How to set date, time / NTP and timezone using timedatectl
  3. How to Calculate Memory Usage in Linux using sar, ps, and free
  4. How to add Swap Space on Linux Servers (CentOS/RHEL) On the Fly
  5. make: Nothing to be done for `default’
  6. Why Does “netstat” Output Show Many Connections in CLOSE_WAIT Status?
  7. update-alternatives: command not found
  8. After Reboot RAID1 Disk Gets Removed/Out of Sync (CentOS/RHEL)
  9. 5 Useful Command Examples to Monitor User Activity under Linux
  10. How to allow or deny telnet login to specific users only in CentOS/RHEL

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright