update-alternatives [option …] command
Creates, removes, maintains and displays information about the symbolic links comprising the Debian
alternatives system.
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.
Debian's 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.
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 call update-alternatives, in particular neither of upgrade nor disappear, 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.
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 man 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.
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).
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.
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 in order to return to the automatic mode (or you can rerun --config and select the entry marked as automatic).
To configure non-interactively use --set instead (see below).
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.
| 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 | 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. |
--install link name path priority [--slave link name path]... |
--altdir directory |
$DPKG_ADMINDIR
If set and --admindir has not been specified, it will be the base administrative directory.
/etc/alternatives/ Tdefault alternatives directory. overridden with --altdir
Example
display the available packages which provide vi and the current setting
/var/lib/dpkg/alternatives/ default administration directory. Overridden with QUERY FORMAT
The --query format is using an RFC822-like flat format. n + 1 blocks where n is the number of alternatives
in the queried link group. The first block contains:
Name: name alternative name in the alternative directory.
Link: link 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.
one slave per line. one space, the generic name of the slave alternative, another space, and the path to the slave link.
Status: AUTO|Manual status of the alternative (auto or manual).
Best: best-choice path of the best alternative for this link group.
Not present if there is no alternatives available.
Value: currently-selected-alternative|none path of the currently selected alternative. It can also take the magic value none. It is used if the link doesn't exist.
The other blocks describe the available alternatives in the queried link group:
Alternative: path-of-this-alternative Path to this block's alternative.
Priority: priority-value Value of the prior0wity 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.
one per line.
Each line contains one space, the generic name of the slave alternative, space, and the path to the slave alternative.
$ 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
DIAGNOSTICS
--verbose
update-alternatives outputs error messages on standard error and returns an exit status of 2.
EXAMPLES
packages which provide a text editor compatible with vi, for example nvi and vim.
link group vi, which includes links for the program itself and the associated manpage.
update-alternatives --display vi
To choose a particular vi implementation & select a number from the list.
update-alternatives --config vi
To go back to having the vi implementation chosen automatically
update-alternatives --auto vi
Midphase
ls -l /etc/alternatives/
cifs-idmap-plugin -> /usr/lib64/cifs-utils/cifs_idmap_sss.so
ld -> /usr/bin/ld.bfd
libnssckbi.so.x86_64 -> /usr/lib64/pkcs11/p11-kit-trust.so
libwbclient.so.0.15-64 -> /usr/lib64/samba/wbclient/libwbclient.so.0.15
mta -> /usr/sbin/sendmail.exim
mta-mailq -> /usr/bin/mailq.exim
mta-mailqman -> /usr/share/man/man8/exim.8.gz
mta-newaliases -> /usr/bin/newaliases.exim
mta-pam -> /etc/pam.d/exim
mta-rmail -> /usr/bin/rmail.exim
mta-rsmtp -> /usr/bin/rsmtp.exim
mta-runq -> /usr/bin/runq.exim
mta-sendmail -> /usr/lib/sendmail.exim
aptitude -> /usr/bin/aptitude-curses*
aptitude.8.gz -> /usr/share/man/man8/aptitude-curses.8.gz and other languages
arptables -> /usr/sbin/arptables-nft*
arptables-restore -> /usr/sbin/arptables-nft-restore*
arptables-save -> /usr/sbin/arptables-nft-save*
awk -> /usr/bin/mawk* awk.1.gz -> /usr/share/man/man1/mawk.1.gz
builtins.7.gz -> /usr/share/man/man7/bash-builtins.7.gz
c++ -> /usr/bin/g++*
c89 -> /usr/bin/c89-gcc* c89.1.gz -> /usr/share/man/man1/c89-gcc.1.gz
c99 -> /usr/bin/c99-gcc* c99.1.gz -> /usr/share/man/man1/c99-gcc.1.gz
cc -> /usr/bin/gcc*
cpp -> /usr/bin/cpp*
cyfmac43455-sdio.bin -> /lib/firmware/cypress/cyfmac43455-sdio-standard.bin
default-GM.sf2 -> /usr/share/sounds/sf2/TimGM6mb.sf2
default-GM.sf3 -> /usr/share/sounds/sf2/TimGM6mb.sf2
desktop-background -> /usr/share/desktop-base/active-theme/wallpaper/contents/images/1920x1080.svg
desktop-background.xml -> /usr/share/desktop-base/active-theme/wallpaper/gnome-background.xml
desktop-grub -> /usr/share/desktop-base/active-theme/grub/grub-4x3.png
desktop-grub.sh -> /usr/share/desktop-base/active-theme/grub/grub_background.sh
desktop-lockscreen.xml -> /usr/share/desktop-base/active-theme/lockscreen/gnome-background.xml
desktop-login-background -> /usr/share/desktop-base/active-theme/login/background.svg
desktop-plasma5-wallpaper -> /usr/share/desktop-base/active-theme/wallpaper/
desktop-theme -> /usr/share/desktop-base/homeworld-theme/
display -> /usr/bin/gpicview* display.1.gz -> /usr/share/man/man1/gpicview.1.gz
ebtables -> /usr/sbin/ebtables-nft*
ebtables-restore -> /usr/sbin/ebtables-nft-restore*
ebtables-save -> /usr/sbin/ebtables-nft-save*
editor -> /bin/nano* editor.1.gz -> /usr/share/man/man1/nano.1.gz
emblem-vendor-128 -> /usr/share/icons/desktop-base/128x128/emblems/emblem-debian.png
emblem-vendor-256 -> /usr/share/icons/desktop-base/256x256/emblems/emblem-debian.png
emblem-vendor-64 -> /usr/share/icons/desktop-base/64x64/emblems/emblem-debian.png
emblem-vendor-scalable -> /usr/share/icons/desktop-base/scalable/emblems/emblem-debian.svg
emblem-vendor-symbolic-128 -> /usr/share/icons/desktop-base/128x128/emblems/emblem-debian-symbolic.png
emblem-vendor-symbolic-256 -> /usr/share/icons/desktop-base/256x256/emblems/emblem-debian-symbolic.png
emblem-vendor-symbolic-64 -> /usr/share/icons/desktop-base/64x64/emblems/emblem-debian-symbolic.png
emblem-vendor-symbolic-scalable -> /usr/share/icons/desktop-base/scalable/emblems/emblem-debian-symbolic.svg
emblem-vendor-white-128 -> /usr/share/icons/desktop-base/128x128/emblems/emblem-debian-white.png
emblem-vendor-white-256 -> /usr/share/icons/desktop-base/256x256/emblems/emblem-debian-white.png
emblem-vendor-white-64 -> /usr/share/icons/desktop-base/64x64/emblems/emblem-debian-white.png
emblem-vendor-white-scalable -> /usr/share/icons/desktop-base/scalable/emblems/emblem-debian-white.svg
ex -> /usr/bin/vim.tiny* ex.1.gz -> /usr/share/man/man1/vim.1.gz and other languages
faked.1.gz -> /usr/share/man/man1/faked-sysv.1.gz and other languages
fakeroot -> /usr/bin/fakeroot-sysv* fakeroot.1.gz -> /usr/share/man/man1/fakeroot-sysv.1.gz pand other languages
gnome-www-browser -> /usr/bin/chromium-browser*
idmap-plugin -> /usr/lib/arm-linux-gnueabihf/cifs-utils/idmapwb.so idmap-plugin.8.gz -> /usr/share/man/man8/idmapwb.8.gz
ip6tables -> /usr/sbin/ip6tables-nft*
ip6tables-restore -> /usr/sbin/ip6tables-nft-restore*
ip6tables-save -> /usr/sbin/ip6tables-nft-save*
iptables -> /usr/sbin/iptables-nft*
iptables-restore -> /usr/sbin/iptables-nft-restore*
iptables-save -> /usr/sbin/iptables-nft-save*
ksh -> /bin/mksh* ksh.1.gz -> /usr/share/man/man1/mksh.1.gz
lft -> /usr/bin/lft.db* lft.1.gz -> /usr/share/man/man1/lft.db.1.gz
libblas.so.3-arm-linux-gnueabihf -> /usr/lib/arm-linux-gnueabihf/blas/libblas.so.3
liblapack.so.3-arm-linux-gnueabihf -> /usr/lib/arm-linux-gnueabihf/lapack/liblapack.so.3
lightdm-greeter -> /usr/share/xgreeters/pi-greeter.desktop
lua-compiler -> /usr/bin/luac5.1* lua-compiler-manual -> /usr/share/man/man1/luac5.1.1.gz
lua-interpreter -> /usr/bin/lua5.1* lua-manual -> /usr/share/man/man1/lua5.1.1.gz
lzcat -> /usr/bin/xzcat* lzcat.1.gz -> /usr/share/man/man1/xzcat.1.gz
lzcmp -> /usr/bin/xzcmp* lzcmp.1.gz -> /usr/share/man/man1/xzcmp.1.gz
lzdiff -> /usr/bin/xzdiff* lzdiff.1.gz -> /usr/share/man/man1/xzdiff.1.gz
lzegrep -> /usr/bin/xzegrep* lzegrep.1.gz -> /usr/share/man/man1/xzegrep.1.gz
lzfgrep -> /usr/bin/xzfgrep* lzfgrep.1.gz -> /usr/share/man/man1/xzfgrep.1.gz
lzgrep -> /usr/bin/xzgrep* lzgrep.1.gz -> /usr/share/man/man1/xzgrep.1.gz
lzless -> /usr/bin/xzless* lzless.1.gz -> /usr/share/man/man1/xzless.1.gz
lzma -> /usr/bin/xz* lzma.1.gz -> /usr/share/man/man1/xz.1.gz
lzmore -> /usr/bin/xzmore* lzmore.1.gz -> /usr/share/man/man1/xzmore.1.gz
mt -> /bin/mt-gnu* mt.1.gz -> /usr/share/man/man1/mt-gnu.1.gz
nawk -> /usr/bin/mawk* nawk.1.gz -> /usr/share/man/man1/mawk.1.gz
nc -> /bin/nc.openbsd* nc.1.gz -> /usr/share/man/man1/nc_openbsd.1.gz
netcat -> /bin/nc.openbsd* netcat.1.gz -> /usr/share/man/man1/nc_openbsd.1.gz
open -> /usr/bin/xdg-open* open.1.gz -> /usr/share/man/man1/xdg-open.1.gz
pager -> /usr/bin/less* pager.1.gz -> /usr/share/man/man1/less.1.gz
pico -> /bin/nano* pico.1.gz -> /usr/share/man/man1/nano.1.gz
pinentry -> /usr/bin/pinentry-gnome3*
pinentry-x11 -> /usr/bin/pinentry-gnome3* pinentry-x11.1.gz -> /usr/share/man/man1/pinentry-gnome3.1.gz
pinentry.1.gz -> /usr/share/man/man1/pinentry-gnome3.1.gz
rcp -> /usr/bin/scp* rcp.1.gz -> /usr/share/man/man1/scp.1.gz
regulatory.db -> /lib/firmware/regulatory.db-debian
regulatory.db.p7s -> /lib/firmware/regulatory.db.p7s-debian
rksh -> /bin/mksh* rksh.1.gz -> /usr/share/man/man1/mksh.1.gz
rlogin -> /usr/bin/slogin* rlogin.1.gz -> /usr/share/man/man1/slogin.1.gz
rmt -> /usr/sbin/rmt-tar* rmt.8.gz -> /usr/share/man/man8/rmt-tar.8.gz
rsh -> /usr/bin/ssh* rsh.1.gz -> /usr/share/man/man1/ssh.1.gz
rst-buildhtml -> /usr/share/docutils/scripts/python3/rst-buildhtml*
rst2html -> /usr/share/docutils/scripts/python3/rst2html*
rst2html4 -> /usr/share/docutils/scripts/python3/rst2html4*
rst2html5 -> /usr/share/docutils/scripts/python3/rst2html5*
rst2latex -> /usr/share/docutils/scripts/python3/rst2latex*
rst2man -> /usr/share/docutils/scripts/python3/rst2man*
rst2odt -> /usr/share/docutils/scripts/python3/rst2odt*
rst2odt_prepstyles -> /usr/share/docutils/scripts/python3/rst2odt_prepstyles*
rst2pseudoxml -> /usr/share/docutils/scripts/python3/rst2pseudoxml*
rst2s5 -> /usr/share/docutils/scripts/python3/rst2s5*
rst2xetex -> /usr/share/docutils/scripts/python3/rst2xetex*
rst2xml -> /usr/share/docutils/scripts/python3/rst2xml*
rstpep2html -> /usr/share/docutils/scripts/python3/rstpep2html*
rview -> /usr/bin/vim.tiny*
start-here-16.png -> /usr/share/icons/gnome/16x16/places/debian-swirl.png
start-here-22.png -> /usr/share/icons/gnome/22x22/places/debian-swirl.png
start-here-24.png -> /usr/share/icons/gnome/24x24/places/debian-swirl.png
start-here-256.png -> /usr/share/icons/gnome/256x256/places/debian-swirl.png
start-here-32.png -> /usr/share/icons/gnome/32x32/places/debian-swirl.png
start-here-48.png -> /usr/share/icons/gnome/48x48/places/debian-swirl.png
start-here.svg -> /usr/share/icons/gnome/scalable/places/debian-swirl.svg
tcptraceroute -> /usr/sbin/tcptraceroute.db* tcptraceroute.8.gz -> /usr/share/man/man8/tcptraceroute.db.8.gz
traceproto -> /usr/bin/traceproto.db* traceproto.1.gz -> /usr/share/man/man1/traceproto.db.1.gz
traceroute -> /usr/bin/traceroute.db* traceroute.1.gz -> /usr/share/man/man1/traceroute.db.1.gz
traceroute.sbin -> /usr/bin/traceroute.db* traceroute6 -> /usr/bin/traceroute6.db*
traceroute6.1.gz -> /usr/share/man/man1/traceroute6.db.1.gz
unlzma -> /usr/bin/unxz* unlzma.1.gz -> /usr/share/man/man1/unxz.1.gz
vendor-logos -> /usr/share/desktop-base/debian-logos/
vi -> /usr/bin/vim.tiny* vi.1.gz -> /usr/share/man/man1/vim.1.gz and other languages
view -> /usr/bin/vim.tiny* view.1.gz -> /usr/share/man/man1/vim.1.gz and other languages
write -> /usr/bin/write.ul* write.1.gz -> /usr/share/man/man1/write.ul.1.gz
x-cursor-theme -> /usr/share/icons/Adwaita/cursor.theme
x-session-manager -> /usr/bin/startlxde-pi*
x-session-manager.1.gz -> /usr/share/man/man1/startlxde.1.gz
x-terminal-emulator -> /usr/bin/lxterminal* x-terminal-emulator.1.gz -> /usr/share/man/man1/lxterminal.1.gz
x-window-manager -> /usr/bin/openbox* x-window-manager.1.gz -> /usr/share/man/man1/openbox.1.gz
x-www-browser -> /usr/bin/chromium-browser*
SEE
ln, FHS (the Filesystem Hierarchy Standard).