update-alternatives(1)
โจ NAME โจ
Okay bestie, this page is update-alternatives(1) from the dpkg suite, and its whole official vibe is: maintain symbolic links determining default commands. Thatโs the NAME line, folded in near the top so we can get straight to the group chat. ๐
๐ฆ SYNOPSIS ๐ฆ
update-alternatives [option...] command
๐ธ DESCRIPTION ๐ธ
So update-alternatives creates, removes, maintains and displays information about the symbolic links that make up the alternatives system. Thatโs the whole assignment. โจ
It is possible for several programs fulfilling the same or similar functions to be installed on a single system at the same time. For example, many systems have several text editors installed at once. This gives choice to the users of a system, allowing each to use a different editor, if desired, but makes it difficult for a program to make a good choice for an editor to invoke if the user has not specified a particular preference. Classic group-project problem, honestly.
The alternatives system aims to solve this problem. A generic name in the filesystem is shared by all files providing interchangeable functionality. The alternatives system and the system administrator together determine which actual file is referenced by this generic name. For example, if the text editors ed(1) and nvi(1) are both installed on the system, the alternatives system will cause the generic name /usr/bin/editor to refer to /usr/bin/nvi by default. The system administrator can override this and cause it to refer to /usr/bin/ed instead, and the alternatives system will not alter this setting until explicitly requested to do so. Respect the adminโs choices, periodt.
The generic name is not a direct symbolic link to the selected alternative. Instead, it is a symbolic link to a name in the alternatives directory, which in turn is a symbolic link to the actual file referenced. This is done so that the system administratorโs changes can be confined within the /etc directory: the FHS (q.v.) gives reasons why this is a Good Thing. ๐ซถ
When each package providing a file with a particular functionality is installed, changed or removed, update-alternatives is called to update information about that file in the alternatives system. update-alternatives is usually called from the following Debian package maintainer scripts, postinst (configure) to install the alternative and from prerm and postrm (remove) to remove the alternative.
Note: In most (if not all) cases no other maintainer script actions should callupdate-alternatives, in particular neither ofupgradenordisappear, as any other such action can lose the manual state of an alternative, or make the alternative temporarily flip-flop, or completely switch when several of them have the same priority. This is the โdo not do the weird thingโ warning, bestie.
It is often useful for a number of alternatives to be synchronized, so that they are changed as a group; for example, when several versions of the vi(1) editor are installed, the manual page referenced by /usr/share/man/man1/vi.1 should correspond to the executable referenced by /usr/bin/vi. update-alternatives handles this by means of master and slave links; when the master is changed, any associated slaves are changed too. A master link and its associated slaves make up a link group. They move as a unit. Iconic.
Each link group is, at any given time, in one of two modes: automatic or manual. When a group is in automatic mode, the alternatives system will automatically decide, as packages are installed and removed, whether and how to update the links. In manual mode, the alternatives system will retain the choice of the administrator and avoid changing the links (except when something is broken). Auto mode is the default bestie; manual mode is โI got this.โ
Link groups are in automatic mode when they are first introduced to the system. If the system administrator makes changes to the systemโs automatic settings, this will be noticed the next time update-alternatives is run on the changed linkโs group, and the group will automatically be switched to manual mode.
Each alternative has a priority associated with it. When a link group is in automatic mode, the alternatives pointed to by members of the group will be those which have the highest priority. Highest priority wins. No cap.
When using the --config option, update-alternatives will list all of the choices for the link group of which given name is the master alternative name. The current choice is marked with a โ*โ. You will then be prompted for your choice regarding this link group. Depending on the choice made, the link group might no longer be in auto mode. You will need to use the --auto option to return to the automatic mode (or you can rerun --config and select the entry marked as automatic). Choose wisely, then maybe undo it. Weโve all been there.
If you want to configure non-interactively you can use the --set option instead (see below). Scriptable queen behavior.
Different packages providing the same file need to do so cooperatively. In other words, the usage of update-alternatives is mandatory for all involved packages in such case. It is not possible to override some file in a package that does not employ the update-alternatives mechanism. Everybody has to opt in, fr fr.
๐ TERMINOLOGY ๐
Since the activities of update-alternatives are quite involved, some specific terms will help to explain its operation. Vocabulary check, bestie โ these words matter.
generic name (or alternative link)
A name, like /usr/bin/editor, which refers, via the alternatives system, to one of a number of files of similar function.
alternative name
The name of a symbolic link in the alternatives directory.
alternative (or alternative path)
The name of a specific file in the filesystem, which may be made accessible via a generic name using the alternatives system.
alternatives directory
A directory, by default /etc/alternatives, containing the symlinks.
administrative directory
A directory, by default /var/lib/dpkg/alternatives, containing update-alternativesโ state information.
link group
A set of related symlinks, intended to be updated as a group.
master link
The alternative link in a link group which determines how the other links in the group are configured.
slave link
An alternative link in a link group which is controlled by the setting of the master link.
automatic mode
When a link group is in automatic mode, the alternatives system ensures that the links in the group point to the highest priority alternative appropriate for the group.
manual mode
When a link group is in manual mode, the alternatives system will not make any changes to the system administratorโs settings.
๐ COMMANDS ๐
Hereโs the command menu, bestie. Every option name, argument, path, number and caveat stays exactly as written โ Iโm just giving it the group-chat energy it deserves. ๐
--install link name path priority [--slave link name path]...โ Add a group of alternatives to the system.linkis the generic name for the master link,nameis the name of its symlink in the alternatives directory, andpathis the alternative being introduced for the master link. The arguments after--slaveare the generic name, symlink name in the alternatives directory and the alternative path for a slave link. Zero or more--slaveoptions, each followed by three arguments, may be specified. Note that the master alternative must exist or the call will fail. However if a slave alternative doesnโt exist, the corresponding slave alternative link will not be installed (a warning will still be displayed). If some real file is installed where an alternative link has to be installed, it is kept unless--forceis used. Also: if the alternativenamespecified exists already in the alternatives systemโs records, the information supplied will be added as a new set of alternatives for the group. Otherwise, a new group, set to automatic mode, will be added with this information. If the group is in automatic mode, and the newly added alternativesโ priority is higher than any other installed alternatives for this group, the symlinks will be updated to point to the newly added alternatives. Big install energy.--set name pathโ Set the programpathas alternative forname. This is equivalent to--configbut is non-interactive and thus scriptable. No prompts, just vibes and automation.--remove name pathโ Remove an alternative and all of its associated slave links.nameis a name in the alternatives directory, andpathis an absolute filename to whichnamecould be linked. Ifnameis indeed linked topath,namewill be updated to point to another appropriate alternative (and the group is put back in automatic mode), or removed if there is no such alternative left. Associated slave links will be updated or removed, correspondingly. If the link is not currently pointing topath, no links are changed; only the information about the alternative is removed. Clean removal, no dramatic side effects.--remove-all nameโ Remove all alternatives and all of their associated slave links.nameis a name in the alternatives directory.--allโ Call--configon all alternatives. It can be usefully combined with--skip-autoto review and configure all alternatives which are not configured in automatic mode. Broken alternatives are also displayed. Thus a simple way to fix all broken alternatives is to callyes '' | update-alternatives --force --all. Yes, thatโs the exact command. Keep the quotes.--auto nameโ Switch the link group behind the alternative fornameto automatic mode. In the process, the master symlink and its slaves are updated to point to the highest priority installed alternatives. Back to auto, bestie.--display nameโ Display information about the link group. Information displayed includes the groupโs mode (auto or manual), the master and slave links, which alternative the master link currently points to, what other alternatives are available (and their corresponding slave alternatives), and the highest priority alternative currently installed. The full tea.--get-selectionsโ List all master alternative names (those controlling a link group) and their status. Each line contains up to 3 fields (separated by one or more spaces). The first field is the alternative name, the second one is the status (eitherautoormanual), and the last one contains the current choice in the alternative (beware: itโs a filename and thus might contain spaces). Supported since version1.15.0.--set-selectionsโ Read configuration of alternatives on standard input in the format generated by--get-selectionsand reconfigure them accordingly. Supported since version1.15.0.--query nameโ Display information about the link group like--displaydoes, but in a machine parseable way (see section"QUERY FORMAT"below). Supported since version1.15.0.--list nameโ Display all targets of the link group.--config nameโ Show available alternatives for a link group and allow the user to interactively select which one to use. The link group is updated. Interactive choice-making, slay.--helpโ Show the usage message and exit.--versionโ Show the version and exit. And thatโs the command list, bestie.
๐ OPTIONS ๐
okay bestie, this is the fun part โ all the little knobs you can twist ๐
--altdirdirectory โ tells it where the alternatives directory lives, for when it's not the default. Defaults to ยซ/etc/alternativesยป.--admindirdirectory โ same vibe but for the administrative directory. Defaults to ยซ/var/lib/dpkg/alternativesยป ifDPKG_ADMINDIRhas not been set.--instdirdirectory โ sets the installation directory, aka the place where alternatives links get created. Defaults to ยซ/ยป ifDPKG_ROOThas not been set.
Supported since version 1.20.1. โจ
--rootdirectory โ sets the root directory. Bestie this is the overachiever: it also sets the alternatives, installation and administrative directories to match. Defaults to ยซ/ยป ifDPKG_ROOThas not been set.
Supported since version 1.20.1. ๐ซถ
--logfile โ picks the log file, for when you don't want the default (/var/log/alternatives.log).
Supported since version 1.15.0. ๐
--forceโ lets you replace or drop any real file that's installed where an alternative link has to be installed or removed. Yes, that's exactly as spicy as it sounds ๐ฅ--skip-autoโ skips the configuration prompt for alternatives that are properly configured in automatic mode. Heads up: this option is only relevant with--configor--all. iykyk.--quietโ no comments at all unless errors happen. silent treatment era ๐--verboseโ more comments about what's being done. it's a talker ๐ฌ--debugโ even more comments, the helpful-for-debugging kind, about what's being done.
Supported since version 1.19.3. ๐
๐ฆ EXIT STATUS ๐ฆ
0โ the requested action was successfully performed. slay ๐2โ problems were encountered whilst parsing the command line or performing the action. we do not love that ๐ญ
๐ฑ ENVIRONMENT ๐ฑ
DPKG_ROOTโ if set and the--instdiror--rootoptions have not been specified, it will be used as the filesystem root directory.DPKG_ADMINDIRโ if set and the--admindiroption has not been specified, it will be used as the base administrative directory.
๐ FILES ๐
/etc/alternatives/โ the default alternatives directory. Can be overridden by the--altdiroption./var/lib/dpkg/alternatives/โ the default administration directory. Can be overridden by the--admindiroption.
๐ QUERY FORMAT ๐
so the --query format is using an RFC822-like flat format. it's made of n + 1 stanzas where n is the number of alternatives available in the queried link group. think of it like a little stack of info cards ๐
the first stanza contains these fields:
Name:name โ the alternative name in the alternative directory.Link:link โ the generic name of the alternative.Slaves:list-of-slaves โ when this field is present, the next lines hold all slave links associated to the master link of the alternative. There is one slave per line. Each line contains one space, the generic name of the slave alternative, another space, and the path to the slave link. (yes, the exact spacing matters, don't come for me ๐)Status:status โ the status of the alternative (autoormanual).Best:best-choice โ the path of the best alternative for this link group. Not present if there is no alternatives available.Value:currently-selected-alternative โ the path of the currently selected alternative. It can also take the magic valuenone. It is used if the link doesn't exist. โจmagicโจ
the other stanzas describe the available alternatives in the queried link group:
Alternative:path-of-this-alternative โ path to this stanza's alternative.Priority:priority-value โ value of the priority of this alternative.Slaves:list-of-slaves โ when this field is present, the next lines hold all slave alternatives associated to the master link of the alternative. There is one slave per line. Each line contains one space, the generic name of the slave alternative, another space, and the path to the slave alternative.
๐ Example ๐
$ update-alternatives --query editor
Name: editor
Link: /usr/bin/editor
Slaves:
editor.1.gz /usr/share/man/man1/editor.1.gz
editor.fr.1.gz /usr/share/man/fr/man1/editor.1.gz
editor.it.1.gz /usr/share/man/it/man1/editor.1.gz
editor.pl.1.gz /usr/share/man/pl/man1/editor.1.gz
editor.ru.1.gz /usr/share/man/ru/man1/editor.1.gz
Status: auto
Best: /usr/bin/vim.basic
Value: /usr/bin/vim.basic
Alternative: /bin/ed
Priority: -100
Slaves:
editor.1.gz /usr/share/man/man1/ed.1.gz
Alternative: /usr/bin/vim.basic
Priority: 50
Slaves:
editor.1.gz /usr/share/man/man1/vim.1.gz
editor.fr.1.gz /usr/share/man/fr/man1/vim.1.gz
editor.it.1.gz /usr/share/man/it/man1/vim.1.gz
editor.pl.1.gz /usr/share/man/pl/man1/vim.1.gz
editor.ru.1.gz /usr/share/man/ru/man1/vim.1.gz
look at all those stanzas. chef's kiss ๐
๐ฉบ DIAGNOSTICS ๐ฉบ
With --verbose, update-alternatives chatters incessantly about its activities on its standard output channel. like, nonstop. main character energy but make it a log stream ๐ฌ
If problems occur, update-alternatives outputs error messages on its standard error channel and returns an exit status of 2.
These diagnostics should be self-explanatory; if you do not find them so, please report this as a bug. (fr fr, they wanna know ๐)
๐ธ EXAMPLES ๐ธ
There are several packages which provide a text editor compatible with vi, for example nvi and vim. Which one is used is controlled by the link group vi, which includes links for the program itself and the associated manual page.
To display the available packages which provide vi and the current setting for it, use the --display action:
update-alternatives --display vi
To choose a particular vi implementation, use this command as root and then select a number from the list:
update-alternatives --config vi
To go back to having the vi implementation chosen automatically, do this as root:
update-alternatives --auto vi
three commands, three vibes, all iconic โจ
๐ SEE ALSO ๐
ln(1), FHS (the Filesystem Hierarchy Standard).
that's a wrap bestie ๐ this page is from version 1.23.11-dirty, dated 2026-09-09 โ go forth and manage your alternatives, you absolute icon ๐๐ฆ
๐ฆ where this page comes from
- arch rolling: dpkg 1.23.11-1 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms