How can I install an RPM without being root?

cd my-dir;
rpm2cpio to-install.rpm | cpio -idv

See How To Extract an RPM Package Without Installing It (rpm extract command).


How to extract rpm packages contents

export ins=foo-bar.rpm
rpm2cpio $ins | cpio -idv

How to extract tar.gz archive

gzip -dc foo-bar.tar.gz | tar xvf –
cd foo-bar-dir

How to extract tar.gz packages to the current directory

export file=foo-bar.tar.gz
# Note that `xovf` switch order *matters*
gzip -dc $file | tar -xovf -

How to build binaries as a non-root

./configure --prefix=$HOME && make && make install

I think the "real" answer to "installing" an rpm without root privilege is, you can't. BUT assuming you could actually start the install process...

RPMs install using a list of instructions provided in a specification file (.spec) that usually follow the Filesystem Hierarchy. Most paths on that hierarchy are almost always operating system paths and not user paths. So unless your username has access to all of the paths an RPM installs to, then it would certainly fail. If you create an RPM that prefixes all of its paths with /home/me (or some other path you own), then it would work. This would require acquiring a src.rpm and extracting it as explained in other answers, then rebuilding it. By the time you do that, you might just consider getting root access or building the software from scratch (usually what you do if you do not plan on distributing the software across many machines).

There are clever tricks to help you in the manual build process. For example, you can utilize the dependencies already listed in an RPM to get all of your dependencies: https://stackoverflow.com/a/13877738/1236128.

Tags:

Linux

Rpm