How to use update-alternatives
This time we are going to look at the
update-alternatives command to maintain symbolic links to chosen defaults.
Let's clear the matter a bit with some common examples for the editors. For example you could choose to install NeoVim (opens new window) but want to call it using
vim as you did previous. So how could we do so? Introducing
vim alternative for
First we need to install the alternative.
sudo update-alternatives --install $(which vim) vim $(which nvim) 10
The first argument
$(which vim) represents the path to symbolic link that we want to mange. In this case it is
The second argument is the name of the command that we want to use in the terminal. You can think of it as the name of the entry. In our case it is
The third argument is the path to the alternative that we want to install. In this case it is
If we now call
update-alternatives with the
--config flag we can choose from the available alternatives.
sudo update-alternatives --config vim
Pick your option using the number shown in the first column.
If there is only one option you will get notified that there is no other option to choose from than the default.
code alternative for
Now let's pick another example. Let's say you have installed VS Code Insiders (opens new window) over the standard VS Code. To start it using the terminal you would need to call
code-insiders instead of
code. So let's add an alternative for
sudo update-alternatives --install $(which code) code $(which code-insiders) 1
Now you can call
update-alternatives again with the
--config flag to choose what you want to start when calling
sudo update-alternatives --config code
code-insiders and from now on you can start it through the
When you don't have installed
code already but want install an alternative for it anyways, then you can just type out the path for it manually. For example for
vim you would use
/usr/bin/vim as first argument.
And that's it. From now you are able to add alternatives for any software you want 🤩