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?

4 Answers 4


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.

  • I ended up creating an "update-alternative"-like script that each user can use for their own needs.
    – Maxime
    Sep 30, 2014 at 7:30

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
for b in llvm-${version}/bin/*; do \
    slaves+=" --slave $HOME/.local/bin/$(basename $b) $(basename $b) $(readlink -f $b)" \
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).


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.


I know this is an old question, but I wanted to chime in with a blatant promotion for the tool I just released that helps you configure per-user (or even per-shell !) alternatives:

You can initialize a shell-specific setup:

$ eval "$( my-alternatives init)"

Or you can initialize a long-lived user-level setup:

# run this once
$ eval "$( my-alternatives init ~/my-alts )"

# place this in your startup scripts
$ eval "$( my-alternatives shellenv ~/my-alts )"

Once configured, setting up a user-local alternative is as easy as:

# equivalent to 'update-alternatives --config <name>'
$ my-alternatives config <name>

NOTE: At the time of this posting, my-alternatives was just released. As such, only init and config logic has been built. Other features will come later.

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.