update-alternatives.8 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. .\" update\-alternatives.8
  2. .\" This man page is copyright 1997 Charles Briscoe-Smith
  3. .\" This is free documentation; you can redistribute it and/or modify
  4. .\" it under the terms of the GNU General Public License as published
  5. .\" by the Free Software Foundation; either version 2 of the License, or
  6. .\" (at your option) any later version. There is NO WARRANTY. You can
  7. .\" find the GNU GPL in /usr/share/common-licenses/GPL on any Debian system.
  8. .TH update\-alternatives 8 "2011-08-14" "Debian Project" "dpkg utilities"
  9. .SH NAME
  10. update\-alternatives \- maintain symbolic links determining default commands
  11. .
  12. .SH SYNOPSIS
  13. .B update\-alternatives
  14. .RI [ option "...] " command
  15. .
  16. .SH DESCRIPTION
  17. .B update\-alternatives
  18. creates, removes, maintains and displays information about the symbolic
  19. links comprising the Debian alternatives system.
  20. .PP
  21. It is possible for several programs fulfilling the same or similar
  22. functions to be installed on a single system at the same time.
  23. For example, many systems have several text editors installed at once.
  24. This gives choice to the users of a system, allowing each to use a
  25. different editor, if desired, but makes it difficult for a program
  26. to make a good choice for an editor to invoke if the
  27. user has not specified a particular preference.
  28. .PP
  29. Debian's alternatives system aims to solve this problem.
  30. A generic name in the filesystem is
  31. shared by all files providing interchangeable functionality.
  32. The alternatives system and the system administrator
  33. together determine which actual file is referenced by this generic name.
  34. For example, if the text editors
  35. .BR ed (1)
  36. and
  37. .BR nvi (1)
  38. are both installed on the system, the alternatives system will cause
  39. the generic name
  40. .I /usr/bin/editor
  41. to refer to
  42. .I /usr/bin/nvi
  43. by default. The system administrator can override this and cause
  44. it
  45. to refer to
  46. .I /usr/bin/ed
  47. instead,
  48. and the alternatives system will not alter this setting until explicitly
  49. requested to do so.
  50. .PP
  51. The generic name is not a direct symbolic link to the selected alternative.
  52. Instead, it is a symbolic link to a name in the
  53. .I alternatives
  54. .IR directory ,
  55. which in turn is a symbolic link to the actual file referenced.
  56. This is done so that the system administrator's changes can be confined
  57. within the
  58. .I /etc
  59. directory: the FHS (q.v.) gives reasons why this is a Good Thing.
  60. .PP
  61. When each package
  62. providing a file with a particular functionality is
  63. installed, changed or removed,
  64. .B update\-alternatives
  65. is called to update information about that file in the alternatives system.
  66. .B update\-alternatives
  67. is usually called from the
  68. .B postinst
  69. (configure) or
  70. .B prerm
  71. (install) scripts in Debian packages.
  72. .PP
  73. It is often useful for a number of alternatives to be synchronised,
  74. so that they are changed as a group; for example, when several versions
  75. of the
  76. .BR vi (1)
  77. editor are installed, the man page referenced by
  78. .I /usr/share/man/man1/vi.1
  79. should correspond to the executable referenced by
  80. .IR /usr/bin/vi .
  81. .B update\-alternatives
  82. handles this by means of
  83. .I master
  84. and
  85. .I slave
  86. links; when the master is changed, any associated slaves are changed
  87. too.
  88. A master link and its associated slaves make up a
  89. .I link
  90. .IR group .
  91. .PP
  92. Each link group is, at any given time,
  93. in one of two modes: automatic or manual.
  94. When a group is in automatic mode, the alternatives system will
  95. automatically decide, as packages are installed and removed,
  96. whether and how to update the links.
  97. In manual mode, the alternatives system will retain the choice of
  98. the administrator and avoid changing the links (except when something is
  99. broken).
  100. .PP
  101. Link groups are in automatic mode when they are first introduced to
  102. the system.
  103. If the system administrator makes changes to the system's
  104. automatic settings,
  105. this will be noticed the next time
  106. .B update\-alternatives
  107. is run on the changed link's group,
  108. and the group will automatically be switched to manual mode.
  109. .PP
  110. Each alternative has a
  111. .I priority
  112. associated with it.
  113. When a link group is in automatic mode,
  114. the alternatives pointed to by members of the group
  115. will be those which have the highest priority.
  116. .PP
  117. When using the
  118. .B \-\-config
  119. option,
  120. .B update\-alternatives
  121. will list all of the choices for the link group
  122. of which given
  123. .I name
  124. is the master alternative name. The current choice is marked with a '*'.
  125. You will then be prompted for your choice regarding this link group.
  126. Depending on the choice made, the link group might no longer be in
  127. .I auto
  128. mode. You will need to use the
  129. .B \-\-auto
  130. option in order to return to the automatic mode (or you can rerun
  131. .B \-\-config
  132. and select the entry marked as automatic).
  133. .PP
  134. If you want to configure non-interactively you can use the
  135. .B \-\-set
  136. option instead (see below).
  137. .PP
  138. Different packages providing the same file need to do so
  139. .BR cooperatively .
  140. In other words, the usage of
  141. .B update\-alternatives
  142. is
  143. .B mandatory
  144. for all involved packages in such case. It is not possible to
  145. override some file in a package that does not employ the
  146. .B update\-alternatives
  147. mechanism.
  148. .
  149. .SH TERMINOLOGY
  150. Since the activities of
  151. .B update\-alternatives
  152. are quite involved, some specific terms will help to explain its
  153. operation.
  154. .TP
  155. generic name (or alternative link)
  156. A name, like
  157. .IR /usr/bin/editor ,
  158. which refers, via the alternatives system, to one of a number of
  159. files of similar function.
  160. .TP
  161. alternative name
  162. The name of a symbolic link in the alternatives directory.
  163. .TP
  164. alternative (or alternative path)
  165. The name of a specific file in the filesystem, which may be made
  166. accessible via a generic name using the alternatives system.
  167. .TP
  168. alternatives directory
  169. A directory, by default
  170. .IR /etc/alternatives ,
  171. containing the symlinks.
  172. .TP
  173. administrative directory
  174. A directory, by default
  175. .IR /var/lib/dpkg/alternatives ,
  176. containing
  177. .BR update\-alternatives '
  178. state information.
  179. .TP
  180. link group
  181. A set of related symlinks, intended to be updated as a group.
  182. .TP
  183. master link
  184. The alternative link in a link group which determines how the other links in the
  185. group are configured.
  186. .TP
  187. slave link
  188. An alternative link in a link group which is controlled by the setting of
  189. the master link.
  190. .TP
  191. automatic mode
  192. When a link group is in automatic mode,
  193. the alternatives system ensures that the links in the group
  194. point to the highest priority alternative
  195. appropriate for the group.
  196. .TP
  197. manual mode
  198. When a link group is in manual mode,
  199. the alternatives system will not make any changes
  200. to the system administrator's settings.
  201. .
  202. .SH COMMANDS
  203. .TP
  204. \fB\-\-install\fR \fIlink name path priority\fR [\fB\-\-slave\fR \fIlink name path\fR]...
  205. Add a group of alternatives to the system.
  206. .I link
  207. is the generic name for the master link,
  208. .I name
  209. is the name of its symlink in the alternatives directory, and
  210. .I path
  211. is the alternative being introduced for the master link.
  212. The arguments after \fB\-\-slave\fR are the generic name, symlink name in the
  213. alternatives directory and the alternative path for a slave link.
  214. Zero or more
  215. .B \-\-slave
  216. options, each followed by three arguments,
  217. may be specified. Note that the master alternative must exist or the call
  218. will fail. However if a slave alternative doesn't exist, the corresponding
  219. slave alternative link will simply not be installed (a warning will still
  220. be displayed). If some real file is installed where an alternative link
  221. has to be installed, it is kept unless \fB\-\-force\fR is used.
  222. .IP
  223. If the alternative name specified exists already
  224. in the alternatives system's records,
  225. the information supplied will be added as a new
  226. set of alternatives for the group.
  227. Otherwise, a new group, set to automatic mode,
  228. will be added with this information.
  229. If the group is in automatic mode,
  230. and the newly added alternatives' priority is higher than
  231. any other installed alternatives for this group,
  232. the symlinks will be updated to point to the newly added alternatives.
  233. .TP
  234. \fB\-\-set\fR \fIname path\fR
  235. Set the program
  236. .I path
  237. as alternative for
  238. .I name.
  239. This is equivalent to
  240. .B \-\-config
  241. but is non-interactive and thus scriptable.
  242. .TP
  243. \fB\-\-remove\fR \fIname path\fR
  244. Remove an alternative and all of its associated slave links.
  245. .I name
  246. is a name in the alternatives directory, and
  247. .I path
  248. is an absolute filename to which
  249. .I name
  250. could be linked. If
  251. .I name
  252. is indeed linked to
  253. .IR path ,
  254. .I name
  255. will be updated to point to another appropriate alternative
  256. (and the group is put back in automatic mode), or
  257. removed if there is no such alternative left.
  258. Associated slave links will be updated or removed, correspondingly.
  259. If the link is not currently pointing to
  260. .IR path ,
  261. no links are changed;
  262. only the information about the alternative is removed.
  263. .TP
  264. \fB\-\-remove\-all\fR \fIname\fR
  265. Remove all alternatives and all of their associated slave links.
  266. .I name
  267. is a name in the alternatives directory.
  268. .TP
  269. .B \-\-all
  270. Call \fB\-\-config\fP on all alternatives. It can be usefully combined with
  271. \fB\-\-skip\-auto\fP to review and configure all alternatives which are
  272. not configured in automatic mode. Broken alternatives are also displayed.
  273. Thus a simple way to fix all broken alternatives is to call
  274. \fByes \[aq]\[aq] | update\-alternatives \-\-force \-\-all\fR.
  275. .TP
  276. \fB\-\-auto\fR \fIname\fR
  277. Switch the link group behind the alternative for
  278. .I name
  279. to automatic mode.
  280. In the process, the master symlink and its slaves are updated
  281. to point to the highest priority installed alternatives.
  282. .TP
  283. \fB\-\-display\fR \fIname\fR
  284. Display information about the link group.
  285. Information displayed includes the group's mode
  286. (auto or manual),
  287. which alternative the master link currently points to,
  288. what other alternatives are available
  289. (and their corresponding slave alternatives),
  290. and the highest priority alternative currently installed.
  291. .TP
  292. \fB\-\-get\-selections\fR
  293. List all master alternative names (those controlling a link group)
  294. and their status. Each line contains up to 3 fields (separated by
  295. one or more spaces). The first field is the alternative name, the second
  296. one is the status (either "auto" or "manual"), and the last one contains
  297. the current choice in the alternative (beware: it's a filename and thus
  298. might contain spaces).
  299. .TP
  300. \fB\-\-set\-selections\fR
  301. Read configuration of alternatives on standard input in the format
  302. generated by \fBupdate\-alternatives \-\-get\-selections\fR and reconfigure
  303. them accordingly.
  304. .TP
  305. \fB\-\-query\fR \fIname\fR
  306. Display information about the link group
  307. like \-\-display does, but in a machine parseable way
  308. (see section \fBQUERY FORMAT\fR below).
  309. .TP
  310. \fB\-\-list\fR \fIname\fR
  311. Display all targets of the link group.
  312. .TP
  313. \fB\-\-config\fR \fIname\fR
  314. Show available alternatives for a link group and allow the user to
  315. interactively select which one to use. The link group is updated.
  316. .TP
  317. .B \-\-help
  318. Show the usage message and exit.
  319. .TP
  320. .B \-\-version
  321. Show the version and exit.
  322. .
  323. .SH OPTIONS
  324. .TP
  325. .BI \-\-altdir " directory"
  326. Specifies the alternatives directory, when this is to be
  327. different from the default.
  328. .TP
  329. .BI \-\-admindir " directory"
  330. Specifies the administrative directory, when this is to be
  331. different from the default.
  332. .TP
  333. .BI \-\-log " file"
  334. Specifies the log file, when this is to be different from the default
  335. (/var/log/alternatives.log).
  336. .TP
  337. .BI \-\-force
  338. Let \fBupdate\-alternatives\fR replace or drop any real file that is installed
  339. where an alternative link has to be installed or removed.
  340. .TP
  341. .BI \-\-skip\-auto
  342. Skip configuration prompt for alternatives which are properly configured
  343. in automatic mode. This option is only relevant with \fB\-\-config\fR or
  344. \fB\-\-all\fR.
  345. .TP
  346. .B \-\-verbose
  347. Generate more comments about what
  348. .B update\-alternatives
  349. is doing.
  350. .TP
  351. .B \-\-quiet
  352. Don't generate any comments unless errors occur.
  353. .
  354. .SH ENVIRONMENT
  355. .TP
  356. .B DPKG_ADMINDIR
  357. If set and the \fB\-\-admindir\fP option has not been specified, it will
  358. be used as the base administrative directory.
  359. .
  360. .SH FILES
  361. .TP
  362. .I /etc/alternatives/
  363. The default alternatives directory.
  364. Can be overridden by the
  365. .B \-\-altdir
  366. option.
  367. .TP
  368. .I /var/lib/dpkg/alternatives/
  369. The default administration directory.
  370. Can be overridden by the
  371. .B \-\-admindir
  372. option.
  373. .
  374. .SH "EXIT STATUS"
  375. .TP
  376. .B 0
  377. The requested action was successfully performed.
  378. .TP
  379. .B 2
  380. Problems were encountered whilst parsing the command line
  381. or performing the action.
  382. .
  383. .SH "QUERY FORMAT"
  384. The \fBupdate\-alternatives \-\-query\fP format is using an
  385. RFC822-like flat format. It's made of \fIn\fP + 1 blocks where \fIn\fP is
  386. the number of alternatives available in the queried link group. The first
  387. block contains the following fields:
  388. .TP
  389. .BI Link: " link"
  390. The generic name of the alternative.
  391. .TP
  392. .BI Status: " status"
  393. The status of the alternative (\fBauto\fR or \fBmanual\fR).
  394. .TP
  395. .BI Best: " best-choice"
  396. The path of the best alternative for this link group. Not present if
  397. there is no alternatives available.
  398. .TP
  399. .BI Value: " currently-selected-alternative"
  400. The path of the currently selected alternative. It can also take the magic
  401. value \fBnone\fR. It is used if the link doesn't exist.
  402. .TP
  403. .TP
  404. The other blocks describe the available alternatives in the queried link group:
  405. .TP
  406. .BI Alternative: " path-of-this-alternative"
  407. Path to this block's alternative.
  408. .TP
  409. .BI Priority: " priority-value"
  410. Value of the priority of this alternative.
  411. .TP
  412. .BI Slaves: " list-of-slaves"
  413. When this header is present, the \fBnext\fR lines hold all slave alternatives
  414. associated to the master link of the alternative. There is one slave per
  415. line. Each line contains one space, the generic name of the slave
  416. alternative, another space, and the path to the slave alternative.
  417. .
  418. .TP
  419. .BR Example
  420. .nf
  421. $ update\-alternatives \-\-query editor
  422. Link: editor
  423. Status: auto
  424. Best: /usr/bin/vim.gtk
  425. Value: /usr/bin/vim.gtk
  426. Alternative: /bin/ed
  427. Priority: \-100
  428. Slaves:
  429. editor.1.gz /usr/share/man/man1/ed.1.gz
  430. Alternative: /usr/bin/vim.gtk
  431. Priority: 50
  432. Slaves:
  433. editor.1.gz /usr/share/man/man1/vim.1.gz
  434. editor.ru.1.gz /usr/share/man/ru/man1/vim.1.gz
  435. editor.pl.ISO8859-2.1.gz /usr/share/man/pl.ISO8859-2/man1/vim.1.gz
  436. editor.it.ISO8859-1.1.gz /usr/share/man/it.ISO8859-1/man1/vim.1.gz
  437. editor.pl.UTF-8.1.gz /usr/share/man/pl.UTF-8/man1/vim.1.gz
  438. editor.it.1.gz /usr/share/man/it/man1/vim.1.gz
  439. editor.fr.UTF-8.1.gz /usr/share/man/fr.UTF-8/man1/vim.1.gz
  440. editor.fr.1.gz /usr/share/man/fr/man1/vim.1.gz
  441. editor.it.UTF-8.1.gz /usr/share/man/it.UTF-8/man1/vim.1.gz
  442. editor.pl.1.gz /usr/share/man/pl/man1/vim.1.gz
  443. editor.fr.ISO8859-1.1.gz /usr/share/man/fr.ISO8859-1/man1/vim.1.gz
  444. .fi
  445. .
  446. .SH DIAGNOSTICS
  447. With \fB\-\-verbose\fR
  448. .B update\-alternatives
  449. chatters incessantly about its activities on its standard output channel.
  450. If problems occur,
  451. .B update\-alternatives
  452. outputs error messages on its standard error channel and
  453. returns an exit status of 2.
  454. These diagnostics should be self-explanatory;
  455. if you do not find them so, please report this as a bug.
  456. .
  457. .SH EXAMPLES
  458. There are several packages which provide a text editor compatible
  459. with \fBvi\fP, for example \fBnvi\fP and \fBvim\fP. Which one is used
  460. is controlled by the link group \fBvi\fP, which includes links for the
  461. program itself and the associated manpage.
  462. .PP
  463. To display the available packages which provide \fBvi\fP and the current
  464. setting for it, use the \fB\-\-display\fP action:
  465. .RS
  466. .PP
  467. .B update\-alternatives \-\-display vi
  468. .RE
  469. .PP
  470. To choose a particular \fBvi\fP implementation, use this command as root
  471. and then select a number from the list:
  472. .RS
  473. .PP
  474. .B update\-alternatives \-\-config vi
  475. .RE
  476. .PP
  477. To go back to having the \fBvi\fP implementation chosen automatically, do
  478. this as root:
  479. .RS
  480. .PP
  481. .B update\-alternatives \-\-auto vi
  482. .RE
  483. .
  484. .SH BUGS
  485. If you find a bug, please report it using the Debian bug-tracking system.
  486. .PP
  487. If you find any discrepancy between the operation of
  488. .B update\-alternatives
  489. and this manual page, it is a bug,
  490. either in the implementation or the documentation; please report it.
  491. .
  492. .SH AUTHORS
  493. Copyright \(co 1995 Ian Jackson
  494. .br
  495. Copyright \(co 2009 Rapha\[:e]l Hertzog
  496. .sp
  497. This is free software; see the GNU General Public Licence version 2 or
  498. later for copying conditions. There is NO WARRANTY.
  499. .PP
  500. This manual page is copyright 1997,1998 Charles Briscoe-Smith and
  501. others.
  502. .sp
  503. This is free documentation; see the GNU General Public Licence version 2 or
  504. later for copying conditions. There is NO WARRANTY.
  505. .
  506. .SH "SEE ALSO"
  507. .BR ln (1),
  508. FHS, the Filesystem Hierarchy Standard.