Update-alternatives can be created, deleted, repaired, soft-connected, and can display information about existing soft links, all of which constitute the Debian alternative system (alternatives systems).
Many times we will install different applications with the same or similar features on the same operating system, such as a different text editor on the same operating system. This gives the user of this system more choice when editing text, and if the user wants them to be free to choose any one to use. But what if the user doesn't specify which editor he wants to use? It's awkward for the program because it doesn't have the same willingness to make a so-called "good" choice.
However, the advent of Debian's alternatives system solves this problem. A common name (generic name) in the file system is shared by those files that have the ability to swap, and the alternative system and system administrator decide which file is specified by the common name (i.e. the alternative system does not completely help the user to manage the soft connection, after all, people-oriented). For example, if the text editor Ed (1) and NVI (1) are installed in a system, and assuming that the alternate system scheme allows the common name (/usr/bin/editor) to point to/usr/bin/nvi by default, then the system administrator can revoke the designation and have the shared name point to/usr /bin/ed, the alternative system will not change this setting unless it is specifically necessary.
In fact, the common name is not a soft connection directly to the selected program (command), but rather a name in the alternative directory (alternatives directory). This name is also a soft connection, which is directly pointing to the selected program (command). The purpose of this mechanism is to restrict the changes made by the administrator to the corresponding configuration file in the/etc directory: FHS can give you a good idea of the benefits of doing so.
When any of the files (Programs/packages) that provide a particular feature are installed, deleted, or changed, Update-alternatives is called to update the information for the corresponding file in the alternative. Update-alternatives is often called by Psstinst (config) or prerm (installation) scripts in the Debian package.
Multiple alternatives that are synchronized for better functioning are called groups; for example, when multiple versions of the VI Editor are installed, the man page specified by/USR/SHARE/MAN/MAN1/VI.1 should be followed by the current/usr/bin/ VI specified version of the vi corresponds to (different versions of VI have their own man, we have to do is to man when the display of the man page and we are using the VI editor corresponding).
Each link group has two different modes: Auto mode and manual mode, and at any given time a group is and can only be one of these modes. If a group is in automatic mode, when the package is installed or deleted, the alternative system will decide for itself whether and how to update the corresponding link (links). If you are in manual mode, the alternative system retains the choices made by the original administrator and avoids changing the links (unless broken occurs).
The link group is assigned to automatic mode when it is first installed to the system, and the group is automatically converted to manual mode if the system administrator makes changes to the mode settings.
Alternatives have their own level (priority), and when a link group is in automatic mode, its members point to high-level alternatives.
When you use the--config option, update-alternatives lists the primary link names for all linked groups, and the currently selected group is marked with a * number. You can make changes to the link point at the prompt, but this changes the mode to manual. If you want to reply to Automatic mode, you can use the--auto option, or--config to re-select the group labeled Automatic.
If you do not want to use the interactive mode provided by--config, you can also use the--set option (more detailed below).
Different packages that provide the same files need to be synchronized, in other words, the use of update-alternatives is useful for the packages that are implicated.