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 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 The 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
65 The system administrator can override this and cause
70 and the alternatives system will not alter this setting until explicitly
73 The generic name is not a direct symbolic link to the selected alternative.
74 Instead, it is a symbolic link to a name in the
77 which in turn is a symbolic link to the actual file referenced.
78 This is done so that the system administrator's changes can be confined
81 directory: the FHS (q.v.) gives reasons why this is a Good Thing.
84 providing a file with a particular functionality is
85 installed, changed or removed,
86 B<update-alternatives>
87 is called to update information about that file in the alternatives system.
88 B<update-alternatives>
89 is usually called from the following Debian package maintainer scripts,
91 (configure) to install the alternative and from
92 B<prerm> and B<postrm>
93 (remove) to remove the alternative.
94 B<Note>: In most (if not all) cases no other maintainer script actions should
95 call B<update-alternatives>, in particular neither of B<upgrade> nor
96 B<disappear>, as any other such action can lose the manual state of an
97 alternative, or make the alternative temporarily flip-flop, or completely
98 switch when several of them have the same priority.
100 It is often useful for a number of alternatives to be synchronized,
101 so that they are changed as a group; for example, when several versions
104 editor are installed, the manual page referenced by
105 I</usr/share/man/man1/vi.1>
106 should correspond to the executable referenced by
108 B<update-alternatives>
109 handles this by means of
113 links; when the master is changed, any associated slaves are changed
115 A master link and its associated slaves make up a
119 Each link group is, at any given time,
120 in one of two modes: automatic or manual.
121 When a group is in automatic mode, the alternatives system will
122 automatically decide, as packages are installed and removed,
123 whether and how to update the links.
124 In manual mode, the alternatives system will retain the choice of
125 the administrator and avoid changing the links (except when something is
128 Link groups are in automatic mode when they are first introduced to
130 If the system administrator makes changes to the system's
132 this will be noticed the next time
133 B<update-alternatives>
134 is run on the changed link's group,
135 and the group will automatically be switched to manual mode.
137 Each alternative has a
140 When a link group is in automatic mode,
141 the alternatives pointed to by members of the group
142 will be those which have the highest priority.
147 B<update-alternatives>
148 will list all of the choices for the link group
151 is the master alternative name.
152 The current choice is marked with a ‘*’.
153 You will then be prompted for your choice regarding this link group.
154 Depending on the choice made, the link group might no longer be in
157 You will need to use the
159 option in order to return to the automatic mode (or you can rerun
161 and select the entry marked as automatic).
163 If you want to configure non-interactively you can use the
165 option instead (see below).
167 Different packages providing the same file need to do so
169 In other words, the usage of
170 B<update-alternatives>
173 for all involved packages in such case.
174 It is not possible to
175 override some file in a package that does not employ the
176 B<update-alternatives>
181 Since the activities of
182 B<update-alternatives>
183 are quite involved, some specific terms will help to explain its
188 =item generic name (or alternative link)
192 which refers, via the alternatives system, to one of a number of
193 files of similar function.
195 =item alternative name
197 The name of a symbolic link in the alternatives directory.
199 =item alternative (or alternative path)
201 The name of a specific file in the filesystem, which may be made
202 accessible via a generic name using the alternatives system.
204 =item alternatives directory
206 A directory, by default
207 I<%CONFDIR%/alternatives>,
208 containing the symlinks.
210 =item administrative directory
212 A directory, by default
213 I<%ADMINDIR%/alternatives>,
215 B<update-alternatives>'
220 A set of related symlinks, intended to be updated as a group.
224 The alternative link in a link group which determines how the other links in the
225 group are configured.
229 An alternative link in a link group which is controlled by the setting of
234 When a link group is in automatic mode,
235 the alternatives system ensures that the links in the group
236 point to the highest priority alternative
237 appropriate for the group.
241 When a link group is in manual mode,
242 the alternatives system will not make any changes
243 to the system administrator's settings.
251 =item B<--install> I<link name path priority> [B<--slave> I<link name path>]...
253 Add a group of alternatives to the system.
255 is the generic name for the master link,
257 is the name of its symlink in the alternatives directory, and
259 is the alternative being introduced for the master link.
260 The arguments after B<--slave> are the generic name, symlink name in the
261 alternatives directory and the alternative path for a slave link.
264 options, each followed by three arguments,
266 Note that the master alternative must exist or the call will fail.
267 However if a slave alternative doesn't exist, the corresponding
268 slave alternative link will simply not be installed (a warning will still
270 If some real file is installed where an alternative link
271 has to be installed, it is kept unless B<--force> is used.
273 If the alternative name specified exists already
274 in the alternatives system's records,
275 the information supplied will be added as a new
276 set of alternatives for the group.
277 Otherwise, a new group, set to automatic mode,
278 will be added with this information.
279 If the group is in automatic mode,
280 and the newly added alternatives' priority is higher than
281 any other installed alternatives for this group,
282 the symlinks will be updated to point to the newly added alternatives.
284 =item B<--set> I<name> I<path>
290 This is equivalent to
292 but is non-interactive and thus scriptable.
294 =item B<--remove> I<name> I<path>
296 Remove an alternative and all of its associated slave links.
298 is a name in the alternatives directory, and
300 is an absolute filename to which
308 will be updated to point to another appropriate alternative
309 (and the group is put back in automatic mode), or
310 removed if there is no such alternative left.
311 Associated slave links will be updated or removed, correspondingly.
312 If the link is not currently pointing to
314 no links are changed;
315 only the information about the alternative is removed.
317 =item B<--remove-all> I<name>
319 Remove all alternatives and all of their associated slave links.
321 is a name in the alternatives directory.
325 Call B<--config> on all alternatives.
326 It can be usefully combined with
327 B<--skip-auto> to review and configure all alternatives which are
328 not configured in automatic mode.
329 Broken alternatives are also displayed.
330 Thus a simple way to fix all broken alternatives is to call
331 B<yes '' | update-alternatives --force --all>.
333 =item B<--auto> I<name>
335 Switch the link group behind the alternative for
338 In the process, the master symlink and its slaves are updated
339 to point to the highest priority installed alternatives.
341 =item B<--display> I<name>
343 Display information about the link group.
344 Information displayed includes the group's mode
346 the master and slave links,
347 which alternative the master link currently points to,
348 what other alternatives are available
349 (and their corresponding slave alternatives),
350 and the highest priority alternative currently installed.
352 =item B<--get-selections>
354 List all master alternative names (those controlling a link group)
355 and their status (since version 1.15.0).
356 Each line contains up to 3 fields (separated by
358 The first field is the alternative name, the second
359 one is the status (either B<auto> or B<manual>), and the last one contains
360 the current choice in the alternative (beware: it's a filename and thus
361 might contain spaces).
363 =item B<--set-selections>
365 Read configuration of alternatives on standard input in the format
366 generated by B<--get-selections> and reconfigure
367 them accordingly (since version 1.15.0).
369 =item B<--query> I<name>
371 Display information about the link group
372 like B<--display> does, but in a machine parseable way
373 (since version 1.15.0, see section L</QUERY FORMAT> below).
375 =item B<--list> I<name>
377 Display all targets of the link group.
379 =item B<--config> I<name>
381 Show available alternatives for a link group and allow the user to
382 interactively select which one to use.
383 The link group is updated.
387 Show the usage message and exit.
391 Show the version and exit.
399 =item B<--altdir> I<directory>
401 Specifies the alternatives directory, when this is to be
402 different from the default.
403 Defaults to «I<%CONFDIR%/alternatives>».
405 =item B<--admindir> I<directory>
407 Specifies the administrative directory, when this is to be
408 different from the default.
409 Defaults to «I<%ADMINDIR%/alternatives>» if B<%ADMINDIR_ENVVAR%> has not
412 =item B<--instdir> I<directory>
414 Specifies the installation directory where alternatives links will be created
415 (since version 1.20.1).
416 Defaults to «I</>» if B<%INSTDIR_ENVVAR%> has not been set.
418 =item B<--root> I<directory>
420 Specifies the root directory (since version 1.20.1).
421 This also sets the alternatives, installation and administrative
422 directories to match.
423 Defaults to «I</>» if B<%INSTDIR_ENVVAR%> has not been set.
425 =item B<--log> I<file>
427 Specifies the log file (since version 1.15.0), when this is to be different
428 from the default (%LOGDIR%/alternatives.log).
432 Allow replacing or dropping any real file that is installed
433 where an alternative link has to be installed or removed.
437 Skip configuration prompt for alternatives which are properly configured
439 This option is only relevant with B<--config> or
444 Do not generate any comments unless errors occur.
448 Generate more comments about what is being done.
452 Generate even more comments, helpful for debugging, about what is being done
453 (since version 1.19.3).
463 The requested action was successfully performed.
467 Problems were encountered whilst parsing the command line
468 or performing the action.
476 =item B<%INSTDIR_ENVVAR%>
478 If set and the B<--instdir> or B<--root> options have not been
479 specified, it will be used as the filesystem root directory.
481 =item B<%ADMINDIR_ENVVAR%>
483 If set and the B<--admindir> option has not been specified, it will
484 be used as the base administrative directory.
492 =item I<%CONFDIR%/alternatives/>
494 The default alternatives directory.
495 Can be overridden by the
499 =item I<%ADMINDIR%/alternatives/>
501 The default administration directory.
502 Can be overridden by the
510 The B<--query> format is using an
511 RFC822-like flat format.
512 It's made of I<n> + 1 stanzas where I<n> is the number of alternatives
513 available in the queried link group.
515 stanza contains the following fields:
519 =item B<Name:> I<name>
521 The alternative name in the alternative directory.
523 =item B<Link:> I<link>
525 The generic name of the alternative.
527 =item B<Slaves:> I<list-of-slaves>
529 When this field is present, the B<next> lines hold all slave links
530 associated to the master link of the alternative.
531 There is one slave per line.
532 Each line contains one space, the generic name of the slave
533 alternative, another space, and the path to the slave link.
535 =item B<Status:> I<status>
537 The status of the alternative (B<auto> or B<manual>).
539 =item B<Best:> I<best-choice>
541 The path of the best alternative for this link group.
543 there is no alternatives available.
545 =item B<Value:> I<currently-selected-alternative>
547 The path of the currently selected alternative.
548 It can also take the magic value B<none>.
549 It is used if the link doesn't exist.
553 The other stanzas describe the available alternatives in the queried
558 =item B<Alternative:> I<path-of-this-alternative>
560 Path to this stanza's alternative.
562 =item B<Priority:> I<priority-value>
564 Value of the priority of this alternative.
566 =item B<Slaves:> I<list-of-slaves>
568 When this field is present, the B<next> lines hold all slave alternatives
569 associated to the master link of the alternative.
570 There is one slave per line.
571 Each line contains one space, the generic name of the slave
572 alternative, another space, and the path to the slave alternative.
578 $ update-alternatives --query editor
580 Link: /usr/bin/editor
582 editor.1.gz /usr/share/man/man1/editor.1.gz
583 editor.fr.1.gz /usr/share/man/fr/man1/editor.1.gz
584 editor.it.1.gz /usr/share/man/it/man1/editor.1.gz
585 editor.pl.1.gz /usr/share/man/pl/man1/editor.1.gz
586 editor.ru.1.gz /usr/share/man/ru/man1/editor.1.gz
588 Best: /usr/bin/vim.basic
589 Value: /usr/bin/vim.basic
594 editor.1.gz /usr/share/man/man1/ed.1.gz
596 Alternative: /usr/bin/vim.basic
599 editor.1.gz /usr/share/man/man1/vim.1.gz
600 editor.fr.1.gz /usr/share/man/fr/man1/vim.1.gz
601 editor.it.1.gz /usr/share/man/it/man1/vim.1.gz
602 editor.pl.1.gz /usr/share/man/pl/man1/vim.1.gz
603 editor.ru.1.gz /usr/share/man/ru/man1/vim.1.gz
608 B<update-alternatives>
609 chatters incessantly about its activities on its standard output channel.
611 B<update-alternatives>
612 outputs error messages on its standard error channel and
613 returns an exit status of 2.
614 These diagnostics should be self-explanatory;
615 if you do not find them so, please report this as a bug.
619 There are several packages which provide a text editor compatible
620 with B<vi>, for example B<nvi> and B<vim>.
622 is controlled by the link group B<vi>, which includes links for the
623 program itself and the associated manual page.
625 To display the available packages which provide B<vi> and the current
626 setting for it, use the B<--display> action:
630 update-alternatives --display vi
634 To choose a particular B<vi> implementation, use this command as root
635 and then select a number from the list:
639 update-alternatives --config vi
643 To go back to having the B<vi> implementation chosen automatically, do
648 update-alternatives --auto vi
655 FHS (the Filesystem Hierarchy Standard).