Sunday, July 27, 2014

update-alternatives

update-alternatives - управляет символическими ссылками, задающими команды по умолчанию.


Терминология
  • generic name (alternative link)  - имя, например, /usr/bin/editor, которое посредством системы альтернатив ссылается на реальный редактор
  • alternative name - имя символической ссылки в папке альтернатив 
  • alternative (alternative path) - имя конкретного файла в файловой системе, например, /bin/nano
  • alternatives directory - папка со ссылками альтернатив (по умолчанию /etc/alternatives)
  • administrative directory - папка с настройками (по умолчанию /var/lib/dpkg/alternatives)
  • link group - группа альтернатив, создаётся для синхронной смены взаимосвязанных альтернатив
  • master link - главная альтернатива в группе; задаёт настройку всей группы
  • slave link - зависимая альтернатива в группе; управляется мастер-линком


Синтаксис
update-alternatives [option...] command

Команды:
--install link name path priority [--slave link name path]...
Add a group of alternatives to the system. link is the generic name for the master link, name is the name of its symlink in the alternatives directory, and path is the alternative being introduced for the master link. 
 The arguments after --slave are the generic name, symlink name in the alternatives directory and the alternative path for a slave link. Zero or more --slave options, each followed by three arguments, may be specified. Note that the master alternative must exist or the call will fail. However if a slave alternative doesn't exist, the corresponding slave alternative link will simply not be installed (a warning will still be displayed). If some real file is installed where an alternative link has to be installed, it is kept unless --force is used.
If the alternative name specified exists already in the alternatives system's records, the information supplied will be added as a new set of alternatives for the group. Otherwise, a new group, set to automatic mode, will be added with this information. If the group is in automatic mode, and the newly added alternatives' priority is higher than any other installed alternatives for this group, the symlinks will be updated to point to the newly added alternatives.

--set name path
Set the program path as alternative for name.  This is equivalent to --config but is non-interactive and thus scriptable.

--remove name path
Remove  an  alternative and all of its associated slave links.  name is a name in the alternatives directory, and path is an absolute filename to which name could be linked. If name is indeed linked to path, name will be updated to point to another appropriate alternative (and the group is put back in automatic mode), or removed if there is no such  alternative  left. Associated slave links will be updated or removed, correspondingly.  If the link is not currently pointing to path, no links are changed; only the information about the alternative is removed.

--remove-all name
Remove all alternatives and all of their associated slave links.  name is a name in the alternatives directory.

--all  
Call  --config  on  all alternatives. It can be usefully combined with --skip-auto to review and configure all alternatives which are not configured in automatic mode. Broken alternatives are also displayed.  Thus a simple way to fix all broken alternatives is to call yes '' | update-alternatives --force --all.

--auto name
Switch the link group behind the alternative for name to automatic mode.  In the process, the master symlink and its slaves are updated to point to the  highest  priority  installed  alternatives.

--display name
Display information about the link group.  Information displayed includes the group's mode (auto or manual), which alternative the master link currently points to, what other alternatives are available (and their corresponding slave alternatives), and the highest priority alternative currently installed.

--get-selections
List all master alternative names (those controlling a link group) and their status. Each line contains up to 3 fields (separated by one or more spaces). The first field  is  the  alternative name, the second one is the status (either "auto" or "manual"), and the last one contains the current choice in the alternative (beware: it's a filename and thus might contain spaces).

--set-selections
Read configuration of alternatives on standard input in the format generated by update-alternatives --get-selections and reconfigure them accordingly.

--query name
Display information about the link group like --display does, but in a machine parseable way (see section QUERY FORMAT in the output of man update-alternatives).

--list name
Display all targets of the link group.

--config name
Show available alternatives for a link group and allow the user to interactively select which one to use. The link group is updated.

--help 
Show the usage message and exit.


Опции:
--altdir directory
Specifies the alternatives directory, when this is to be different from the default.

--admindir directory
Specifies the administrative directory, when this is to be different from the default.

--log file
Specifies the log file, when this is to be different from the default (/var/log/alternatives.log).

--force
Let update-alternatives replace or drop any real file that is installed where an alternative link has to be installed or removed.

--skip-auto
Skip configuration prompt for alternatives which are properly configured in automatic mode. 
This option is only relevant with --config or --all.

--verbose
Generate more comments about what update-alternatives is doing.

--quiet
Don't generate any comments unless errors occur.