What is a system of alternatives, briefly but not bad, is set out in a wikipedia article , which I recommend to read before reading further.
What is the meaning of auto mode and manual mode , I will try to explain with the example of the vim program.
- You put a fresh system, and in it there is no this program at all.
You installed the vim package. it includes (including) the file /usr/bin/vim.basic
, and in the /usr/bin/vim.basic
script (using the update-alternatives program) this file is registered as an alternative for the file /usr/bin/vim
with priority 30 (why exactly 30 ? well, so the accompanying package decided). Also such chain of links turns out:
/usr/bin/vim → /etc/alternatives/vim → /usr/bin/vim.basic
- After that you installed the vim-gtk package, which includes (including) the file
/usr/bin/vim.gtk
, and in the /usr/bin/vim.gtk
script this file is registered as an alternative to the same file /usr/bin/vim
, but with priority 50. and since the set of alternatives for the /usr/bin/vim
file was currently in "auto mode", the update-alternatives program (which was called in the post-installation script of the vim-gtk package) selects the current alternative which has higher priority, i.e. /usr/bin/vim.gtk
. and it turns out a slightly different chain of links:
/usr/bin/vim → /etc/alternatives/vim → /usr/bin/vim.gtk
but if you ran sudo update-alternatives --config vim
before installing the vim-gtk package and manually chose the /usr/bin/vim.basic
option (and it doesn't matter that it was the only one at that time), then alternatives would switch to “manual mode” ( manual mode ), and after installing the vim-gtk package, switching alternatives wouldn’t happen, the old link chain remains relevant:
/usr/bin/vim → /etc/alternatives/vim → /usr/bin/vim.basic
where are all these priorities fixed, possible alternatives, the current mode ( auto / manual ) for, for example, the vim program? in the /var/lib/dpkg/alternatives/vim
file:
manual /usr/bin/vim /usr/bin/vim.basic 30 /usr/bin/vim.gtk 50
The first line is the mode ( auto or manual ), the second line is the file itself, for which further alternatives are listed with their priorities.
and how to get back the "auto-mode"?
$ sudo update-alternatives --auto vim
It is worth noting that “auto-mode” is “turned on” by default when registering the very first alternative for a file. and “manual mode” is “turned on” after using the option of --config имя
the update-alternatives program you manually specified to use one of the alternatives. (in general, of course, it is possible without update-alternatives , change the first line in the file /var/lib/dpkg/alternatives/имя
).