How do I install an application by DEB file for a single user only?

When installing applications via the software center or by a DEB file they will usually be installed system wide for all users.

Is there a way to install an application for a single user only?


Solution 1:

Well dpkg won't help you as this isn't its design aim. It wants to be a root-owned sole census of packages installed on a system.

The only thing that jumps to mind is just extracting the package and trying to place the files manually in the home dir.

However this will only work for some things. Plenty of packages are split into chunks (executables or scripts in /usr/bin, libraries in /lib and other garb in /usr/share, etc) and these locations are hard-coded in by the build scripts. Thus if you try and pull in something like this into ~, it will break. You could spend hours unwinding the dependencies but you could be doing something useful with your time like finding the cure for cancer or absorbing some of the beauty in the world.

You'd do much better just to grab a non-packaged version from whoever writes the software. Almost all free software is available in some form of compressed archive as source so grab that and just build it. You don't do the make install step. Your app is built, just put it where you want it.

Solution 2:

I don't know too much about this subject, but it seems from the other answers that you may be able to install a package to another directory instead of / with dpkg, using the --root parameter, and then do a chroot to the dir which the package was "installed" in (which can of course be a dir in the home directory of the user).

To install a package for a user other than root, it might be possible to use the above process with fakechroot instead of chroot.

Disclaimer: I did not try this, and do not have much experience at the time of writing with dpkg or chroot, but from what I do know about these tools, this process just might work.

Links which have information which may be useful for people who want to achieve the effect of chroot without root capabilities:

  • This page about read-only bind mounts (it seems that this can be useful even to people doing a "standard" chroot
  • This page on serverfault.com
  • These pages about Linux Containers
  • The man page for fakechroot)

Update

I now have done a little bit with things which touch on this subject, and found out some more...

Fragments (local environment building blocks):

  • Fakechroot - emulates chroot(1)
  • Debootstrap - Create another Debian file system hierarchy inside a directory
  • Fakeroot-NG/fakeroot - Can pretend to be root for some things
  • EmDebian - A debian variant which uses less space and is often used in chroot environments
  • binfmt_misc - Can run files, using their interpreters, as if they are native binaries; useful together with qemu-user for working with binaries (or in a (fake)chroot) of foreign architectures (scripts/qemu-binfmt-conf.sh which comes with the QEMU source code automates this)
  • Qemu user space - Can run binaries of other architectures; can be used with some of these tools when they do not support some processor architectures
  • LwIP - A TCP/IP networking stack which can be run from user space

Full (complete local environment providers):

  • User mode linux - runs another linux system as a regular process/program
  • Qemu - Run a complete virtual computer
  • PRoot - Provides functionalities of chroot(1), mount --bind, binfmt_misc, and running binaries from other architectures using qemu-user-space
  • Linux namespaces - Allows to have full root inside a local environment, when using user namespaces, a feature that is available in Linux kernel versions 3.8 and after.

Summary: By emulating, or actually having, root privileges locally, DEB packages can be installed for a local environment.