[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Correct way to select alternatives



On Tue, 6 Jul 1999, Kristopher Johnson wrote:

> What is the correct way to switch between different "alternatives"?  For
> example, currently my /usr/bin/vi points to nvi.  What is the right way
> to change it to point to vim or elvis?  I know how to use 'ln -s' to
> create/change links, but I suspect that I should really use
> 'update-alternatives' or some related mechanism.  I've read the
> update-alternatives man page, but didn't understand it--it seems to
> apply only to package maintainers.

IIRC, you're supposed to manually change the sumlinks in /etc/alternatives
to make the change. The update-alternatives program will then recognize
that you made changes, and change the mode for that setup to 'manual'. The
--auto option can be used later to have the system automatically pick the
"best" one again.

A session might go something like this:
  # cd /etc/alternatives
  # update-alternatives --display vi
  vi - status is auto.
   link currently points to /usr/bin/nvi
  /usr/bin/nvi - priority 30
   slave vi.1.gz: /usr/man/man1/nvi.1.gz
  /usr/bin/vim - priority 20
   slave vi.1.gz: /usr/man/man1/vim.1.gz
  Current `best' version is /usr/bin/nvi.
  # rm vi vi.1.gz 
  # ln -s /usr/bin/vim vi
  # ln -s /usr/man/man1/vim.1.gz vi.1.gz

Note that you should update the slave links, so the manpages match the
binary.

The next time you install a program that offers a vi alternative, you'll
get a message something like this:

  /etc/alternatives/vi has been changed (manually or by a script).
  Switching to manual updates only.
  Checking available versions of vi, updating links in /etc/alternatives...
  (You may modify the symlinks there yourself if desired - see `man ln'.)
  Automatic updates of /etc/alternatives/vi are disabled, leaving it alone.
  To return to automatic updates use `update-alternatives --auto vi'.

If you want to force this, just tell it to remove something that isn't an
alternative, like "update-alternatives --remove vi /tmp". It'll give an
error message, but it will set manual mode.

Later on, if you want to go back to automatic updates, just run the
command "update-alternatives --auto vi" and it will do so.

  # update-alternatives --auto vi
  Setting up automatic selection of vi.
  Checking available versions of vi, updating links in /etc/alternatives...
  (You may modify the symlinks there yourself if desired - see `man ln'.)
  Updating vi (/usr/bin/vi) to point to /usr/bin/nvi.
  Updating vi.1.gz (/usr/man/man1/vi.1.gz) to point to
  /usr/man/man1/nvi.1.gz.

If there's a better way, please enlighten me! (:



Reply to: