Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

6 Answers 6

up vote 5 down vote accepted

Depending on what you want to accomplish, there may be different ways to make this work (or at least give a hacky semblance of the functionality you want).

Installation of software in many ways comes down to making resources available, or allowing access to things that are already present on the system.

Whether you are talking about granting access to printers, or allowing a user to execute programs in a certain directory, there are ways to accomplish this, and though they may be native to Ubuntu, these kinds of solutions are generally (of course) going to be added after the fact of a .deb installation.

Here are two general classes of post-installation control that can be added. Note that, given the right environment, e.g. when a tightly controlled group policy is in place, this might be easier once you have the basic system in place. These kind of permission can even be tied to LDAP or a similar system which can give per-user or group authentication and authorization.

Visiblity control
I've had a perhaps somewhat similar situation myself, but in my case, the users were not (yet) very sophisticated (all of them being under 7 years old). For me, just hiding Gnome menus and or removing desktop launchers worked.

Removing the executable bit from directories eliminates the ability of processes to search or traverse them. It can effectively render them invisible, and user-wise, make them unavailable. If you have a default system policy which creates menus based on file access, for instance, you can get this kind of cosmetic solution in place, and then have it work for subsequent installations with little additional effort.

Execution control
Control of the resource can be done via Unix permissions, apparmor profiles, SELinux permissions, and so on. There may be other levels of control filtering which may come into play depending on the application. In the absence of more targeted solutions, you might have to write wrappers around certain programs to control user or process access.

share|improve this answer
3  
+1 for separating the visibility and the execution control aspect –  Takkat Mar 2 '11 at 8:55

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.

share|improve this answer
    
As for the last option: it seems to me that it may help in some (simple programme) cases, but usually the package for example installs init scripts to /etc/init, looks for config files in /etc, or has some other paths hardcoded. –  arrange Mar 2 '11 at 20:41
    
Projects based on autoconf may allow to set a custom install dir via ./configure --prefix=$HOME/local. –  Ingo Karkat Sep 17 '12 at 19:16

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:

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.

share|improve this answer
3  
Feel free to reformat your answer completely if you have information that contradicts your previous info (or if you think it adds anything). In many cases your answer will be more clear if you rephrase instead of adding additional "Edit" or "Update" sections. Your information is interesting, but the possibly most relevant parts are stuck at the bottom. –  belacq Mar 2 '11 at 5:36
    
@jgbelacqua - reformatted, thank you for the tip. –  Abbafei Mar 2 '11 at 22:27

You can probably use the --root option of dpkg to install to another directory. But will probably run into problems if the application looks for stuff in fixed places like /etc.

In short, I don't think there is an easy way.

share|improve this answer

You could change the executable file's ownership so that only one user would be able to run it. Then, if needed, you can remove the application from the menus of other users.

share|improve this answer
1  
A common motivation for wanting to install an application for a single user is to avoid needing to use administrative privileges for the installation. –  ændrük Mar 1 '11 at 21:04
    
@ændrük But if he's already installing from a .deb, aren't we assuming admin privileges? –  belacq Mar 2 '11 at 6:21
    
@jgbelacqua To my knowledge, yes, installing from a .deb requires admin privileges. But, more generally, installing something "for a single user only" should never require elevation to the privileges used for system-wide administration. For example, I frequently install programs for only myself by placing them in ~/bin. There is an ambiguity in this question about whether Takkat wants to restrict access/visibility of a multi-user application, or whether he wants to install a single-user application. Your and arrange's questions use the former interpretation, and the rest assume the latter. –  ændrük Mar 2 '11 at 19:34

Doubtful.

The deb's are mainly archives that get extracted to the root of your filesystem when installed (plus some config). If you wanted to install them just for one user, you would need to somehow install them to /home/user folder. Even if you did so, they wouldn't work, as f.e. application binaries won't land in /usr/bin (or sth similar), and system will not find them if you'll try to launch them. Similarly libraries etc. would be useless, as the system wouldn't know there are somewhere in the /home. You could try the brute-force approach, and adjust the PATH variable to point to wherever you extracted the files from the deb archive, but that would be not only VERY insecure, but might cause may compatibility problems (f.e. menu entries wouldn't work, as GNOME extects the .desktop files to be in /usr/share/applications).

Moreover, if you installed a package just for some users, it might cause crazy dependency problems, if any other user installed package that conflicts with another one you have had installed just for yourself - and possibly tons of other package management related issues would appear.

All these troubles make it extremely difficult to manage packages separately for users, so it seems it's not possible to install them just for one user, because the idea behind the .debs disallows that.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.