How do I install an RPM package into a different directory?

Q. How do I install an RPM package into a different directory like /home/chroot under RHEL / Fedora / CentOS Linux server?

A.An RPM package that can be installed into a different directory is said to be relocatable. The –prefix NEWPATH option is used for for relocatable binary packages. It translate all file paths that start with the installation prefix in the package relocation hint(s) to NEWPATH. For example, package bind-chroot or rsync or bash can be installed into another directory called /opt or /home/chroot. First find out whether a particular package is relocatable or not using rpm -qi command itself:
$ rpm -qi {package-name}
To install an RPM package into a diffrent directory type:
# rpm --prefix=/home/chroot/ bind-chroot*.rpm
To verify package file listing enter:
# rpm -ql bind-chroot

ADVERTISEMENTS

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
6 comments… add one
  • Reynold Sep 6, 2011 @ 3:58

    Thanks for the post Vivek:)
    It would be great if you could include the relocation concept in debain packages also ….

  • tahir Apr 30, 2012 @ 8:21

    sir how i convert a folder because in that folder there is exe files so i convert it into rpm form to install that through rpm….. rply

  • Sanjith Nov 27, 2012 @ 12:37

    how do i remove the packages installed with –prefix directory?
    plz help

  • Felipe Aug 28, 2014 @ 14:15

    # rpm –prefix=/opt/tomcat -ivh tomcat-7.0.42-8.el7_0.noarch.rpm
    error: package tomcat is not relocatable

  • nix Aug 12, 2015 @ 8:43

    rpm –relocate /opt/tomcat -ivh tomcat-7.0.42-8.el7_0.noarch.rpm

  • Vikas Garg Dec 13, 2017 @ 6:19

    Thanks a lot boss.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.