1 # dpkg manual page - update-alternatives(1)
3 # Copyright © 1997-1998 Charles Briscoe-Smith
4 # Copyright © 1999 Ben Collins <bcollins@debian.org>
5 # Copyright © 2000 Wichert Akkerman <wakkerma@debian.org>
6 # Copyright © 2003 Adam Heath <doogie@debian.org>
7 # Copyright © 2005 Scott James Remnant <scott@netsplit.com>
8 # Copyright © 2006-2015 Guillem Jover <guillem@debian.org>
9 # Copyright © 2008 Pierre Habouzit <madcoder@debian.org>
10 # Copyright © 2009-2011 Raphaël Hertzog <hertzog@debian.org>
12 # This is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # This is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program. If not, see <https://www.gnu.org/licenses/>.
29 update-alternatives - maintain symbolic links determining default commands
33 B<update-alternatives>
34 [I<option>...] I<command>
38 B<update-alternatives>
39 creates, removes, maintains and displays information about the symbolic
40 links comprising the Debian alternatives system.
42 It is possible for several programs fulfilling the same or similar
43 functions to be installed on a single system at the same time.
44 For example, many systems have several text editors installed at once.
45 This gives choice to the users of a system, allowing each to use a
46 different editor, if desired, but makes it difficult for a program
47 to make a good choice for an editor to invoke if the
48 user has not specified a particular preference.
50 Debian's alternatives system aims to solve this problem.
51 A generic name in the filesystem is
52 shared by all files providing interchangeable functionality.
53 The alternatives system and the system administrator
54 together determine which actual file is referenced by this generic name.
55 For example, if the text editors
59 are both installed on the system, the alternatives system will cause
64 by default. The system administrator can override this and cause
69 and the alternatives system will not alter this setting until explicitly
72 The generic name is not a direct symbolic link to the selected alternative.
73 Instead, it is a symbolic link to a name in the
76 which in turn is a symbolic link to the actual file referenced.
77 This is done so that the system administrator's changes can be confined
80 directory: the FHS (q.v.) gives reasons why this is a Good Thing.
83 providing a file with a particular functionality is
84 installed, changed or removed,
85 B<update-alternatives>
86 is called to update information about that file in the alternatives system.
87 B<update-alternatives>
88 is usually called from the following Debian package maintainer scripts,
90 (configure) to install the alternative and from
91 B<prerm> and B<postrm>
92 (remove) to remove the alternative.
93 B<Note>: in most (if not all) cases no other maintainer script actions should
94 call B<update-alternatives>, in particular neither of B<upgrade> nor
95 B<disappear>, as any other such action can lose the manual state of an
96 alternative, or make the alternative temporarily flip-flop, or completely
97 switch when several of them have the same priority.
99 It is often useful for a number of alternatives to be synchronized,
100 so that they are changed as a group; for example, when several versions
103 editor are installed, the manual page referenced by
104 I</usr/share/man/man1/vi.1>
105 should correspond to the executable referenced by
107 B<update-alternatives>
108 handles this by means of
112 links; when the master is changed, any associated slaves are changed
114 A master link and its associated slaves make up a
118 Each link group is, at any given time,
119 in one of two modes: automatic or manual.
120 When a group is in automatic mode, the alternatives system will
121 automatically decide, as packages are installed and removed,
122 whether and how to update the links.
123 In manual mode, the alternatives system will retain the choice of
124 the administrator and avoid changing the links (except when something is
127 Link groups are in automatic mode when they are first introduced to
129 If the system administrator makes changes to the system's
131 this will be noticed the next time
132 B<update-alternatives>
133 is run on the changed link's group,
134 and the group will automatically be switched to manual mode.
136 Each alternative has a
139 When a link group is in automatic mode,
140 the alternatives pointed to by members of the group
141 will be those which have the highest priority.
146 B<update-alternatives>
147 will list all of the choices for the link group
150 is the master alternative name.
151 The current choice is marked with a ‘*’.
152 You will then be prompted for your choice regarding this link group.
153 Depending on the choice made, the link group might no longer be in
155 mode. You will need to use the
157 option in order to return to the automatic mode (or you can rerun
159 and select the entry marked as automatic).
161 If you want to configure non-interactively you can use the
163 option instead (see below).
165 Different packages providing the same file need to do so
167 In other words, the usage of
168 B<update-alternatives>
171 for all involved packages in such case. It is not possible to
172 override some file in a package that does not employ the
173 B<update-alternatives>
178 Since the activities of
179 B<update-alternatives>
180 are quite involved, some specific terms will help to explain its
185 =item generic name (or alternative link)
189 which refers, via the alternatives system, to one of a number of
190 files of similar function.
192 =item alternative name
194 The name of a symbolic link in the alternatives directory.
196 =item alternative (or alternative path)
198 The name of a specific file in the filesystem, which may be made
199 accessible via a generic name using the alternatives system.
201 =item alternatives directory
203 A directory, by default
204 I<%CONFDIR%/alternatives>,
205 containing the symlinks.
207 =item administrative directory
209 A directory, by default
210 I<%ADMINDIR%/alternatives>,
212 B<update-alternatives>'
217 A set of related symlinks, intended to be updated as a group.
221 The alternative link in a link group which determines how the other links in the
222 group are configured.
226 An alternative link in a link group which is controlled by the setting of
231 When a link group is in automatic mode,
232 the alternatives system ensures that the links in the group
233 point to the highest priority alternative
234 appropriate for the group.
238 When a link group is in manual mode,
239 the alternatives system will not make any changes
240 to the system administrator's settings.
248 =item B<--install> I<link name path priority> [B<--slave> I<link name path>]...
250 Add a group of alternatives to the system.
252 is the generic name for the master link,
254 is the name of its symlink in the alternatives directory, and
256 is the alternative being introduced for the master link.
257 The arguments after B<--slave> are the generic name, symlink name in the
258 alternatives directory and the alternative path for a slave link.
261 options, each followed by three arguments,
262 may be specified. Note that the master alternative must exist or the call
263 will fail. However if a slave alternative doesn't exist, the corresponding
264 slave alternative link will simply not be installed (a warning will still
265 be displayed). If some real file is installed where an alternative link
266 has to be installed, it is kept unless B<--force> is used.
268 If the alternative name specified exists already
269 in the alternatives system's records,
270 the information supplied will be added as a new
271 set of alternatives for the group.
272 Otherwise, a new group, set to automatic mode,
273 will be added with this information.
274 If the group is in automatic mode,
275 and the newly added alternatives' priority is higher than
276 any other installed alternatives for this group,
277 the symlinks will be updated to point to the newly added alternatives.
279 =item B<--set> I<name> I<path>
285 This is equivalent to
287 but is non-interactive and thus scriptable.
289 =item B<--remove> I<name> I<path>
291 Remove an alternative and all of its associated slave links.
293 is a name in the alternatives directory, and
295 is an absolute filename to which
302 will be updated to point to another appropriate alternative
303 (and the group is put back in automatic mode), or
304 removed if there is no such alternative left.
305 Associated slave links will be updated or removed, correspondingly.
306 If the link is not currently pointing to
308 no links are changed;
309 only the information about the alternative is removed.
311 =item B<--remove-all> I<name>
313 Remove all alternatives and all of their associated slave links.
315 is a name in the alternatives directory.
319 Call B<--config> on all alternatives. It can be usefully combined with
320 B<--skip-auto> to review and configure all alternatives which are
321 not configured in automatic mode. Broken alternatives are also displayed.
322 Thus a simple way to fix all broken alternatives is to call
323 B<yes '' | update-alternatives --force --all>.
325 =item B<--auto> I<name>
327 Switch the link group behind the alternative for
330 In the process, the master symlink and its slaves are updated
331 to point to the highest priority installed alternatives.
333 =item B<--display> I<name>
335 Display information about the link group.
336 Information displayed includes the group's mode
338 the master and slave links,
339 which alternative the master link currently points to,
340 what other alternatives are available
341 (and their corresponding slave alternatives),
342 and the highest priority alternative currently installed.
344 =item B<--get-selections>
346 List all master alternative names (those controlling a link group)
347 and their status (since version 1.15.0).
348 Each line contains up to 3 fields (separated by
349 one or more spaces). The first field is the alternative name, the second
350 one is the status (either B<auto> or B<manual>), and the last one contains
351 the current choice in the alternative (beware: it's a filename and thus
352 might contain spaces).
354 =item B<--set-selections>
356 Read configuration of alternatives on standard input in the format
357 generated by B<--get-selections> and reconfigure
358 them accordingly (since version 1.15.0).
360 =item B<--query> I<name>
362 Display information about the link group
363 like B<--display> does, but in a machine parseable way
364 (since version 1.15.0, see section B<QUERY FORMAT> below).
366 =item B<--list> I<name>
368 Display all targets of the link group.
370 =item B<--config> I<name>
372 Show available alternatives for a link group and allow the user to
373 interactively select which one to use. The link group is updated.
377 Show the usage message and exit.
381 Show the version and exit.
389 =item B<--altdir> I<directory>
391 Specifies the alternatives directory, when this is to be
392 different from the default.
393 Defaults to «I<%CONFDIR%/alternatives>».
395 =item B<--admindir> I<directory>
397 Specifies the administrative directory, when this is to be
398 different from the default.
399 Defaults to «I<%ADMINDIR%/alternatives>» if B<%ADMINDIR_ENVVAR%> has not
402 =item B<--instdir> I<directory>
404 Specifies the installation directory where alternatives links will be created
405 (since version 1.20.1).
406 Defaults to «I</>» if B<%INSTDIR_ENVVAR%> has not been set.
408 =item B<--root> I<directory>
410 Specifies the root directory (since version 1.20.1).
411 This also sets the alternatives, installation and administrative
412 directories to match.
413 Defaults to «I</>» if B<%INSTDIR_ENVVAR%> has not been set.
415 =item B<--log> I<file>
417 Specifies the log file (since version 1.15.0), when this is to be different
418 from the default (%LOGDIR%/alternatives.log).
422 Allow replacing or dropping any real file that is installed
423 where an alternative link has to be installed or removed.
427 Skip configuration prompt for alternatives which are properly configured
428 in automatic mode. This option is only relevant with B<--config> or
433 Do not generate any comments unless errors occur.
437 Generate more comments about what is being done.
441 Generate even more comments, helpful for debugging, about what is being done
442 (since version 1.19.3).
452 The requested action was successfully performed.
456 Problems were encountered whilst parsing the command line
457 or performing the action.
465 =item B<%INSTDIR_ENVVAR%>
467 If set and the B<--instdir> or B<--root> options have not been
468 specified, it will be used as the filesystem root directory.
470 =item B<%ADMINDIR_ENVVAR%>
472 If set and the B<--admindir> option has not been specified, it will
473 be used as the base administrative directory.
481 =item I<%CONFDIR%/alternatives/>
483 The default alternatives directory.
484 Can be overridden by the
488 =item I<%ADMINDIR%/alternatives/>
490 The default administration directory.
491 Can be overridden by the
499 The B<--query> format is using an
500 RFC822-like flat format. It's made of I<n> + 1 stanzas where I<n> is
501 the number of alternatives available in the queried link group. The first
502 stanza contains the following fields:
506 =item B<Name:> I<name>
508 The alternative name in the alternative directory.
510 =item B<Link:> I<link>
512 The generic name of the alternative.
514 =item B<Slaves:> I<list-of-slaves>
516 When this field is present, the B<next> lines hold all slave links
517 associated to the master link of the alternative. There is one slave per
518 line. Each line contains one space, the generic name of the slave
519 alternative, another space, and the path to the slave link.
521 =item B<Status:> I<status>
523 The status of the alternative (B<auto> or B<manual>).
525 =item B<Best:> I<best-choice>
527 The path of the best alternative for this link group. Not present if
528 there is no alternatives available.
530 =item B<Value:> I<currently-selected-alternative>
532 The path of the currently selected alternative. It can also take the magic
533 value B<none>. It is used if the link doesn't exist.
537 The other stanzas describe the available alternatives in the queried
542 =item B<Alternative:> I<path-of-this-alternative>
544 Path to this stanza's alternative.
546 =item B<Priority:> I<priority-value>
548 Value of the priority of this alternative.
550 =item B<Slaves:> I<list-of-slaves>
552 When this field is present, the B<next> lines hold all slave alternatives
553 associated to the master link of the alternative. There is one slave per
554 line. Each line contains one space, the generic name of the slave
555 alternative, another space, and the path to the slave alternative.
561 $ update-alternatives --query editor
563 Link: /usr/bin/editor
565 editor.1.gz /usr/share/man/man1/editor.1.gz
566 editor.fr.1.gz /usr/share/man/fr/man1/editor.1.gz
567 editor.it.1.gz /usr/share/man/it/man1/editor.1.gz
568 editor.pl.1.gz /usr/share/man/pl/man1/editor.1.gz
569 editor.ru.1.gz /usr/share/man/ru/man1/editor.1.gz
571 Best: /usr/bin/vim.basic
572 Value: /usr/bin/vim.basic
577 editor.1.gz /usr/share/man/man1/ed.1.gz
579 Alternative: /usr/bin/vim.basic
582 editor.1.gz /usr/share/man/man1/vim.1.gz
583 editor.fr.1.gz /usr/share/man/fr/man1/vim.1.gz
584 editor.it.1.gz /usr/share/man/it/man1/vim.1.gz
585 editor.pl.1.gz /usr/share/man/pl/man1/vim.1.gz
586 editor.ru.1.gz /usr/share/man/ru/man1/vim.1.gz
591 B<update-alternatives>
592 chatters incessantly about its activities on its standard output channel.
594 B<update-alternatives>
595 outputs error messages on its standard error channel and
596 returns an exit status of 2.
597 These diagnostics should be self-explanatory;
598 if you do not find them so, please report this as a bug.
602 There are several packages which provide a text editor compatible
603 with B<vi>, for example B<nvi> and B<vim>. Which one is used
604 is controlled by the link group B<vi>, which includes links for the
605 program itself and the associated manpage.
607 To display the available packages which provide B<vi> and the current
608 setting for it, use the B<--display> action:
612 update-alternatives --display vi
616 To choose a particular B<vi> implementation, use this command as root
617 and then select a number from the list:
621 update-alternatives --config vi
625 To go back to having the B<vi> implementation chosen automatically, do
630 update-alternatives --auto vi
637 FHS (the Filesystem Hierarchy Standard).