update-alternatives.1 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. .\" dpkg manual page - update-alternatives(1)
  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-2015 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 <https://www.gnu.org/licenses/>.
  24. .
  25. .TH update\-alternatives 1 "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. (remove and deconfigure) 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.
  142. The current choice is marked with a \(oq*\(cq.
  143. You will then be prompted for your choice regarding this link group.
  144. Depending on the choice made, the link group might no longer be in
  145. .I auto
  146. mode. You will need to use the
  147. .B \-\-auto
  148. option in order to return to the automatic mode (or you can rerun
  149. .B \-\-config
  150. and select the entry marked as automatic).
  151. .PP
  152. If you want to configure non-interactively you can use the
  153. .B \-\-set
  154. option instead (see below).
  155. .PP
  156. Different packages providing the same file need to do so
  157. .BR cooperatively .
  158. In other words, the usage of
  159. .B update\-alternatives
  160. is
  161. .B mandatory
  162. for all involved packages in such case. It is not possible to
  163. override some file in a package that does not employ the
  164. .B update\-alternatives
  165. mechanism.
  166. .
  167. .SH TERMINOLOGY
  168. Since the activities of
  169. .B update\-alternatives
  170. are quite involved, some specific terms will help to explain its
  171. operation.
  172. .TP
  173. generic name (or alternative link)
  174. A name, like
  175. .IR /usr/bin/editor ,
  176. which refers, via the alternatives system, to one of a number of
  177. files of similar function.
  178. .TP
  179. alternative name
  180. The name of a symbolic link in the alternatives directory.
  181. .TP
  182. alternative (or alternative path)
  183. The name of a specific file in the filesystem, which may be made
  184. accessible via a generic name using the alternatives system.
  185. .TP
  186. alternatives directory
  187. A directory, by default
  188. .IR /etc/alternatives ,
  189. containing the symlinks.
  190. .TP
  191. administrative directory
  192. A directory, by default
  193. .IR /var/lib/dpkg/alternatives ,
  194. containing
  195. .BR update\-alternatives '
  196. state information.
  197. .TP
  198. link group
  199. A set of related symlinks, intended to be updated as a group.
  200. .TP
  201. master link
  202. The alternative link in a link group which determines how the other links in the
  203. group are configured.
  204. .TP
  205. slave link
  206. An alternative link in a link group which is controlled by the setting of
  207. the master link.
  208. .TP
  209. automatic mode
  210. When a link group is in automatic mode,
  211. the alternatives system ensures that the links in the group
  212. point to the highest priority alternative
  213. appropriate for the group.
  214. .TP
  215. manual mode
  216. When a link group is in manual mode,
  217. the alternatives system will not make any changes
  218. to the system administrator's settings.
  219. .
  220. .SH COMMANDS
  221. .TP
  222. \fB\-\-install\fR \fIlink name path priority\fR [\fB\-\-slave\fR \fIlink name path\fR]...
  223. Add a group of alternatives to the system.
  224. .I link
  225. is the generic name for the master link,
  226. .I name
  227. is the name of its symlink in the alternatives directory, and
  228. .I path
  229. is the alternative being introduced for the master link.
  230. The arguments after \fB\-\-slave\fR are the generic name, symlink name in the
  231. alternatives directory and the alternative path for a slave link.
  232. Zero or more
  233. .B \-\-slave
  234. options, each followed by three arguments,
  235. may be specified. Note that the master alternative must exist or the call
  236. will fail. However if a slave alternative doesn't exist, the corresponding
  237. slave alternative link will simply not be installed (a warning will still
  238. be displayed). If some real file is installed where an alternative link
  239. has to be installed, it is kept unless \fB\-\-force\fR is used.
  240. .IP
  241. If the alternative name specified exists already
  242. in the alternatives system's records,
  243. the information supplied will be added as a new
  244. set of alternatives for the group.
  245. Otherwise, a new group, set to automatic mode,
  246. will be added with this information.
  247. If the group is in automatic mode,
  248. and the newly added alternatives' priority is higher than
  249. any other installed alternatives for this group,
  250. the symlinks will be updated to point to the newly added alternatives.
  251. .TP
  252. \fB\-\-set\fR \fIname path\fR
  253. Set the program
  254. .I path
  255. as alternative for
  256. .I name.
  257. This is equivalent to
  258. .B \-\-config
  259. but is non-interactive and thus scriptable.
  260. .TP
  261. \fB\-\-remove\fR \fIname path\fR
  262. Remove an alternative and all of its associated slave links.
  263. .I name
  264. is a name in the alternatives directory, and
  265. .I path
  266. is an absolute filename to which
  267. .I name
  268. could be linked. If
  269. .I name
  270. is indeed linked to
  271. .IR path ,
  272. .I name
  273. will be updated to point to another appropriate alternative
  274. (and the group is put back in automatic mode), or
  275. removed if there is no such alternative left.
  276. Associated slave links will be updated or removed, correspondingly.
  277. If the link is not currently pointing to
  278. .IR path ,
  279. no links are changed;
  280. only the information about the alternative is removed.
  281. .TP
  282. \fB\-\-remove\-all\fR \fIname\fR
  283. Remove all alternatives and all of their associated slave links.
  284. .I name
  285. is a name in the alternatives directory.
  286. .TP
  287. .B \-\-all
  288. Call \fB\-\-config\fP on all alternatives. It can be usefully combined with
  289. \fB\-\-skip\-auto\fP to review and configure all alternatives which are
  290. not configured in automatic mode. Broken alternatives are also displayed.
  291. Thus a simple way to fix all broken alternatives is to call
  292. \fByes \[aq]\[aq] | update\-alternatives \-\-force \-\-all\fR.
  293. .TP
  294. \fB\-\-auto\fR \fIname\fR
  295. Switch the link group behind the alternative for
  296. .I name
  297. to automatic mode.
  298. In the process, the master symlink and its slaves are updated
  299. to point to the highest priority installed alternatives.
  300. .TP
  301. \fB\-\-display\fR \fIname\fR
  302. Display information about the link group.
  303. Information displayed includes the group's mode
  304. (auto or manual),
  305. which alternative the master link currently points to,
  306. what other alternatives are available
  307. (and their corresponding slave alternatives),
  308. and the highest priority alternative currently installed.
  309. .TP
  310. \fB\-\-get\-selections\fR
  311. List all master alternative names (those controlling a link group)
  312. and their status (since version 1.15.0).
  313. Each line contains up to 3 fields (separated by
  314. one or more spaces). The first field is the alternative name, the second
  315. one is the status (either \fBauto\fP or \fBmanual\fP), and the last one contains
  316. the current choice in the alternative (beware: it's a filename and thus
  317. might contain spaces).
  318. .TP
  319. \fB\-\-set\-selections\fR
  320. Read configuration of alternatives on standard input in the format
  321. generated by \fBupdate\-alternatives \-\-get\-selections\fR and reconfigure
  322. them accordingly (since version 1.15.0).
  323. .TP
  324. \fB\-\-query\fR \fIname\fR
  325. Display information about the link group
  326. like \-\-display does, but in a machine parseable way
  327. (since version 1.15.0, see section \fBQUERY FORMAT\fR below).
  328. .TP
  329. \fB\-\-list\fR \fIname\fR
  330. Display all targets of the link group.
  331. .TP
  332. \fB\-\-config\fR \fIname\fR
  333. Show available alternatives for a link group and allow the user to
  334. interactively select which one to use. The link group is updated.
  335. .TP
  336. .B \-\-help
  337. Show the usage message and exit.
  338. .TP
  339. .B \-\-version
  340. Show the version and exit.
  341. .
  342. .SH OPTIONS
  343. .TP
  344. .BI \-\-altdir " directory"
  345. Specifies the alternatives directory, when this is to be
  346. different from the default.
  347. .TP
  348. .BI \-\-admindir " directory"
  349. Specifies the administrative directory, when this is to be
  350. different from the default.
  351. .TP
  352. .BI \-\-log " file"
  353. Specifies the log file (since version 1.15.0), when this is to be different
  354. from the default (/var/log/alternatives.log).
  355. .TP
  356. .BI \-\-force
  357. Let \fBupdate\-alternatives\fR replace or drop any real file that is installed
  358. where an alternative link has to be installed or removed.
  359. .TP
  360. .BI \-\-skip\-auto
  361. Skip configuration prompt for alternatives which are properly configured
  362. in automatic mode. This option is only relevant with \fB\-\-config\fR or
  363. \fB\-\-all\fR.
  364. .TP
  365. .B \-\-verbose
  366. Generate more comments about what
  367. .B update\-alternatives
  368. is doing.
  369. .TP
  370. .B \-\-quiet
  371. Don't generate any comments unless errors occur.
  372. .
  373. .SH EXIT STATUS
  374. .TP
  375. .B 0
  376. The requested action was successfully performed.
  377. .TP
  378. .B 2
  379. Problems were encountered whilst parsing the command line
  380. or performing the action.
  381. .
  382. .SH ENVIRONMENT
  383. .TP
  384. .B DPKG_ADMINDIR
  385. If set and the \fB\-\-admindir\fP option has not been specified, it will
  386. be used as the base administrative directory.
  387. .
  388. .SH FILES
  389. .TP
  390. .I /etc/alternatives/
  391. The default alternatives directory.
  392. Can be overridden by the
  393. .B \-\-altdir
  394. option.
  395. .TP
  396. .I /var/lib/dpkg/alternatives/
  397. The default administration directory.
  398. Can be overridden by the
  399. .B \-\-admindir
  400. option.
  401. .
  402. .SH QUERY FORMAT
  403. The \fBupdate\-alternatives \-\-query\fP format is using an
  404. RFC822-like flat format. It's made of \fIn\fP + 1 blocks where \fIn\fP is
  405. the number of alternatives available in the queried link group. The first
  406. block contains the following fields:
  407. .TP
  408. .BI Name: " name"
  409. The alternative name in the alternative directory.
  410. .TP
  411. .BI Link: " link"
  412. The generic name of the alternative.
  413. .TP
  414. .BI Slaves: " list-of-slaves"
  415. When this field is present, the \fBnext\fR lines hold all slave links
  416. associated to the master link of the alternative. There is one slave per
  417. line. Each line contains one space, the generic name of the slave
  418. alternative, another space, and the path to the slave link.
  419. .TP
  420. .BI Status: " status"
  421. The status of the alternative (\fBauto\fR or \fBmanual\fR).
  422. .TP
  423. .BI Best: " best-choice"
  424. The path of the best alternative for this link group. Not present if
  425. there is no alternatives available.
  426. .TP
  427. .BI Value: " currently-selected-alternative"
  428. The path of the currently selected alternative. It can also take the magic
  429. value \fBnone\fR. It is used if the link doesn't exist.
  430. .TP
  431. .TP
  432. The other blocks describe the available alternatives in the queried link group:
  433. .TP
  434. .BI Alternative: " path-of-this-alternative"
  435. Path to this block's alternative.
  436. .TP
  437. .BI Priority: " priority-value"
  438. Value of the priority of this alternative.
  439. .TP
  440. .BI Slaves: " list-of-slaves"
  441. When this field is present, the \fBnext\fR lines hold all slave alternatives
  442. associated to the master link of the alternative. There is one slave per
  443. line. Each line contains one space, the generic name of the slave
  444. alternative, another space, and the path to the slave alternative.
  445. .
  446. .TP
  447. .BR Example
  448. .nf
  449. $ update\-alternatives \-\-query editor
  450. Name: editor
  451. Link: /usr/bin/editor
  452. Slaves:
  453. editor.1.gz /usr/share/man/man1/editor.1.gz
  454. editor.fr.1.gz /usr/share/man/fr/man1/editor.1.gz
  455. editor.it.1.gz /usr/share/man/it/man1/editor.1.gz
  456. editor.pl.1.gz /usr/share/man/pl/man1/editor.1.gz
  457. editor.ru.1.gz /usr/share/man/ru/man1/editor.1.gz
  458. Status: auto
  459. Best: /usr/bin/vim.basic
  460. Value: /usr/bin/vim.basic
  461. Alternative: /bin/ed
  462. Priority: \-100
  463. Slaves:
  464. editor.1.gz /usr/share/man/man1/ed.1.gz
  465. Alternative: /usr/bin/vim.basic
  466. Priority: 50
  467. Slaves:
  468. editor.1.gz /usr/share/man/man1/vim.1.gz
  469. editor.fr.1.gz /usr/share/man/fr/man1/vim.1.gz
  470. editor.it.1.gz /usr/share/man/it/man1/vim.1.gz
  471. editor.pl.1.gz /usr/share/man/pl/man1/vim.1.gz
  472. editor.ru.1.gz /usr/share/man/ru/man1/vim.1.gz
  473. .fi
  474. .
  475. .SH DIAGNOSTICS
  476. With \fB\-\-verbose\fR
  477. .B update\-alternatives
  478. chatters incessantly about its activities on its standard output channel.
  479. If problems occur,
  480. .B update\-alternatives
  481. outputs error messages on its standard error channel and
  482. returns an exit status of 2.
  483. These diagnostics should be self-explanatory;
  484. if you do not find them so, please report this as a bug.
  485. .
  486. .SH EXAMPLES
  487. There are several packages which provide a text editor compatible
  488. with \fBvi\fP, for example \fBnvi\fP and \fBvim\fP. Which one is used
  489. is controlled by the link group \fBvi\fP, which includes links for the
  490. program itself and the associated manpage.
  491. .PP
  492. To display the available packages which provide \fBvi\fP and the current
  493. setting for it, use the \fB\-\-display\fP action:
  494. .RS
  495. .PP
  496. .B update\-alternatives \-\-display vi
  497. .RE
  498. .PP
  499. To choose a particular \fBvi\fP implementation, use this command as root
  500. and then select a number from the list:
  501. .RS
  502. .PP
  503. .B update\-alternatives \-\-config vi
  504. .RE
  505. .PP
  506. To go back to having the \fBvi\fP implementation chosen automatically, do
  507. this as root:
  508. .RS
  509. .PP
  510. .B update\-alternatives \-\-auto vi
  511. .RE
  512. .
  513. .SH SEE ALSO
  514. .BR ln (1),
  515. FHS, the Filesystem Hierarchy Standard.