10

Is there any way to use update-alternative "user wide" ? I mean that it would be great to set preferences per user.

Does Debian provide some tools for that?

0

Each user can create their own bin directory for example in ~/bin and put that first in their PATH. Inside that directory they can have symlinks to their preferred alternative.

I don't know whether they can use the update-alternative command to update their own directory of symlinks, or if they have to do that manually.

| improve this answer | |
  • I ended up creating an "update-alternative"-like script that each user can use for their own needs. – Maxime Sep 30 '14 at 7:30
11

Yes, you can absolutely use update-alternatives for yourself. For example, I have different LLVM versions installed under ~/.local/llvm-VERSION. I can install binary links into ~/.local/bin (which is in my $PATH) like this:

alias update-my-alternatives='update-alternatives --altdir ~/.local/etc/alternatives --admindir ~/.local/var/lib/alternatives'
mkdir -p ~/.local/var/lib/alternatives ~/.local/etc/alternatives
version=3.9.0
slaves=""
for b in llvm-${version}/bin/*; do \
    slaves+=" --slave $HOME/.local/bin/$(basename $b) $(basename $b) $(readlink -f $b)" \
done
update-my-alternatives --install $HOME/.local/bin/llvm-config llvm $(readlink -f $(dirname $b)/llvm-config) ${version//./0} ${slaves}

I can repeat the last command for new versions and use update-my-alternatives --config llvm to choose between versions.

If you want to use the pre-existing system alternatives, you could possibly copy over all the files in /var/lib/alternatives to ~/.local/var/lib/alternatives and change all of the system paths in the first section to be user paths (e.g. change /usr to /home/username/.local).

| improve this answer | |
1

Users who don't want to use the system default for an application that uses the alternatives (and an alternate is indeed installed) can always simply use either the correct name or full path for the non-default alternative or set up an alias overruling the symbolic link.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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