57

What does /etc/alternatives stand for? How and why is it used?

I found gnome-tex-editor in /usr/bin which is linked as follows:

/usr/bin/gnome-text-editor -> /etc/alternatives/gnome-text-editor
/etc/alternatives/gnome-text-editor -> /usr/bin/gedit

So gedit and gnome-text-editor seem to be the same thing.

So why are some commands (e.g.: gedit and gnome-text-editor) provided twice?

And what is the use of /etc/alternatives/ - how does it work?

Suman
  • 501
Pandya
  • 35,771
  • 44
  • 128
  • 188

1 Answers1

50

There are some programs that are considered generic. Many programs can provide the required functionality.

For example, view is one such meta-program that can be provided by any tool capable of displaying text, such as more,less,vim,etc.

/etc/alternatives is a directory that is used in keeping track of the alternatives currently in use, by a tool called update-alternatives.

For more information, read the manual page by man update-alternatives in a terminal. Also visit Debian Alternatives System.

Pandya
  • 35,771
  • 44
  • 128
  • 188
Mahesh
  • 12,738
  • 1
    As an example for how to use it, I had a problem that nvim was hijacking vim (I probably did it a long time ago) and now wanted to use vim. I first ran update-alternatives --query vim, which is very helpful it showed that it would link to vim.basic, but that nvim was the default. Then I ran update-alternatives --remove vim /usr/bin/nvim, this now meant that vim would link to /usr/bin/vim.basic which is what I wanted. – icc97 Oct 16 '20 at 12:12