Differences between revisions 7 and 8
Revision 7 as of 2014-04-03 19:13:57
Size: 2910
Editor: MichaelSmith
Comment: Remove unnecessary subshell/ls parsing from oneliners. Ref: http://mywiki.wooledge.org/BashPitfalls#for_i_in_.24.28ls_.2A.mp3.29
Revision 8 as of 2018-02-27 13:23:24
Size: 3043
Editor: ccts
Comment: this page mixes various intents and probably needs to get tidied
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
''If you are looking for all other mechanisms to set default applications, refer to [[DesktopDefaultSettings|this page]].''

----

Translation(s): English - Italiano - Русский


If you are looking for all other mechanisms to set default applications, refer to this page.


Debian Alternatives System

The Debian alternatives system creates a way for several programs that fulfill the same or similar functions to be listed as alternative implementations that are installed simultaneously but with one particular implementation designated as the default. For example many systems have several text editors installed at the same time. The vi program is a classic example of an editor that has many implementations such as nvi, elvis, vim, etc. but which one should be designated as the default?

Debian's alternatives system aims to solve the problem of selecting a default preferred version. Management is done through the update-alternatives program that creates, removes, maintains and displays information about the symbolic links constituting the Debian alternatives system. Priorities are assigned by package creators. The alternative with the highest priority determines the default value when in automatic mode. Additionally the local administrator may override the automatic selection with a manual selection.

The Debian alternatives system was originally created for Debian but has been picked up by other GNU/Linux software distributions. For example Red Hat now uses a fork of the code to maintain system software such as /usr/sbin/sendmail. On RHEL/Fedora /usr/sbin/sendmail is an alternatives symlink to either the classic Sendmail or to Postfix as alternative implementations of an MTA. In fact the alternative group is called the mta group there.

Here is a previous rant on the subject in the debian-user mailing list that I think is a good introduction to using the Debian alternatives system. I will eventually pull most of that discussion into this wiki page but for now I will just reference it.

One-Liners to manipulate alternatives

Here is a long one-liner that will print out all manually configured Debian Alternatives symlinks.

for i in /etc/alternatives/*; do 
  LANG=C update-alternatives --display "${i#/etc/alternatives/}"
done 2>/dev/null | awk '/manual.mode/{print $1}'

If all of those are something that you want to reset to automatic then this can be done using the same generated list. Otherwise simply grep out the ones that you want or don't want.

for i in /etc/alternatives/*; do
  LANG=C update-alternatives --display "${i#/etc/alternatives/}"
done 2>/dev/null |
  awk '/manual.mode/{print $1}' | 
  xargs -L 1 sudo update-alternatives --auto

See Also