LKBEN11053: Howto change the alternatives from the command line on a debian alike system


You need to change an alternative (/etc/alternatives) on your system


Needed for extra configuration


The alternatives system is used to configure symbolic links for system commands. This makes it possible to configure your system to your own needs.

e.g. You can set your specific editor or the version of qmake you want to run.

To show you the current link for a certain command you can use the following.

update-alternatives --display <command>

e.g. update-alternatives --display vi

This will show you something like:

vi - status is auto.
 link currently points to /usr/bin/vim
/usr/bin/vim - priority 35
 slave vi.1.gz: /usr/share/man/man1/vim.1.gz
Current `best' version is /usr/bin/vim.

You could have used the following command to find out the current link too:

ls -l `which vi`

This will show you something like:

lrwxrwxrwx 1 root root 20 2006-10-01 02:31 /usr/bin/vi -> /etc/alternatives/vi

When there are real alternatives you will find the priority of the alternative in the output.

update-alternatives --display qmake

qmake - status is manual.
 link currently points to /usr/bin/qmake-qt4
/usr/bin/qmake-qt3 - priority 45
/usr/bin/qmake-qt4 - priority 40
 slave qmake.1.gz: /usr/share/man/man1/qmake-qt4.1.gz
Current `best' version is /usr/bin/qmake-qt3.

You can see that in this case there are two possibilities. (qmake-qt3 and qmake-qt4) You can even see a proposition for the best current version.

To change the alternative from the command line you can use:

sudo /usr/sbin/update-alternatives --config qmake

There are 2 alternatives which provide `qmake'.

  Selection    Alternative
 +    1        /usr/bin/qmake-qt3
*     2        /usr/bin/qmake-qt4

You can interactively choose your option. The sudo is needed when you are not logged in as root. In this case you can leave the sudo in the command line.
You will get a "Permission denied" error when you are not root on the system.

You will get the message "No alternatives for <command name>" when there are no alternatives available for the command.


The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!

About the Author

Author: Wim Peeters - Keskon GmbH & Co. KG

Wim Peeters is electronics engineer with an additional master in IT and over 30 years of experience, including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform.