Friday, April 23, 2010

Debian alternatives system

Debian alternatives system allows the administrator to select a default out of a set of programmes that provide the same functionality. To stay with the example of the text editor, Debian systems provide /usr/bin/editor, and every package providing a text editor registers with the alternatives system as a provider of the functionality expected from /usr/bin/editor. Now, other software can rely on /usr/bin/editor to invoke a text editor, but the decision which editor is to be used is placed in the hands of the administrator.
deby01:~# update-alternatives --list editor
/bin/ed
/bin/nano
/usr/bin/vim.tiny
Add VIM to alternatives:
deby01:~# update-alternatives --install /usr/bin/editor editor /usr/bin/vim 20
deby01:~# update-alternatives --config editor

There are 4 alternatives which provide `editor'.

  Selection    Alternative
-----------------------------------------------
          1    /bin/ed
*+        2    /bin/nano
          3    /usr/bin/vim.tiny
          4    /usr/bin/vim

Press enter to keep the default[*], or type selection number: 4
Using '/usr/bin/vim' to provide 'editor'.

deby01:~# readlink /etc/alternatives/editor
/usr/bin/vim
Once these changes have been applied visudo will use vim as your editor.

No comments :

Post a Comment