update-alternatives.8 16 KB

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