Is there any way to get APT to install packages to my home directory?

Dpkg do not have the --relocate feature that RPM has. It's worth considering how many RPM packages support that feature though. Basically, it can't be done.

What you could do is use a chroot if you want to test something before installing it globally on the system. To do this, you need to be able to get access to root. The first thing to do is to create a basic chroot:

# debootstrap lenny lenny-chroot

This creates a Lenny chroot inside the lenny-chroot directory.

Now we can enter the chroot:

# chroot lenny-chroot

Now we can do what ever we want and install anything without it messing up the rest of the system. When we're done, just type exit or press ctrl-D


Linuxbrew is another non-root package manager for Linux (based on the popular Homebrew package management system for OS X) that compiles from source and keeps binaries in your home directory.

Quoting the docs, Linuxbrew features are:

  • Can install software to a home directory and so does not require sudo
  • Install software not packaged by the native distribution
  • Install up-to-date versions of software when the native distribution is old
  • Use the same package manager to manage both your Mac and Linux machines

Gentoo prefix does exactly what you want.

It installs all packages into a specified directory. No root access required. If you want to get rid of it, just remove the base directory.

  • See a developer's post for some intro.
  • Detailed use cases
  • Installation(?) info
  • Project's page

PS: This does not work on Ubuntu >= 11.04, or any other Debian derivative with Multiarch.


Just as a minor addition to the option of compiling it, there's the half-way option of compiling into a package with a different prefix option at compile time (with "checkinstall" or perhaps some other method). The advantage is that the package will appear on package managers such as aptitude or synaptic.

Besides that I think it may be possible in some cases to download the actual .deb and force a different prefix via dpkg install, but I think that it's not something that can be done with any random package, but they got to have been compiled with some variable for their location (rather than the literal explicit prefix) that you'd export before installing. I don't know anything about the procedure though, google for "dpkg instdir prefix".


You can use fakechroot - have a look at the demo on their website.