{
    "content": [
        {
            "type": "text",
            "text": "# update-alternatives (man)\n\n## NAME\n\nupdate-alternatives - maintain symbolic links determining default commands\n\n## SYNOPSIS\n\nupdate-alternatives [option...] command\n\n## DESCRIPTION\n\nupdate-alternatives creates, removes, maintains and displays information about the symbolic\nlinks comprising the Debian alternatives system.\n\n## TLDR\n\n> Convenientily maintain symbolic links to determine default commands.\n\n- Add a symbolic link:\n  `sudo update-alternatives --install {{path/to/symlink}} {{command_name}} {{path/to/command_binary}} {{priority}}`\n- Configure a symbolic link for `java`:\n  `sudo update-alternatives --config java`\n- Remove a symbolic link:\n  `sudo update-alternatives --remove {{java}} {{/opt/java/jdk1.8.0_102/bin/java}}`\n- Display information about a specified command:\n  `update-alternatives --display {{java}}`\n- Display all commands and their current selection:\n  `update-alternatives --get-selections`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **TERMINOLOGY**\n- **COMMANDS** (5 subsections)\n- **OPTIONS** (5 subsections)\n- **EXIT STATUS**\n- **ENVIRONMENT**\n- **FILES**\n- **QUERY FORMAT** (1 subsections)\n- **DIAGNOSTICS**\n- **EXAMPLES**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "update-alternatives",
        "section": "",
        "mode": "man",
        "summary": "update-alternatives - maintain symbolic links determining default commands",
        "synopsis": "update-alternatives [option...] command",
        "tldr_summary": "Convenientily maintain symbolic links to determine default commands.",
        "tldr_examples": [
            {
                "description": "Add a symbolic link",
                "command": "sudo update-alternatives --install {{path/to/symlink}} {{command_name}} {{path/to/command_binary}} {{priority}}"
            },
            {
                "description": "Configure a symbolic link for `java`",
                "command": "sudo update-alternatives --config java"
            },
            {
                "description": "Remove a symbolic link",
                "command": "sudo update-alternatives --remove {{java}} {{/opt/java/jdk1.8.0_102/bin/java}}"
            },
            {
                "description": "Display information about a specified command",
                "command": "update-alternatives --display {{java}}"
            },
            {
                "description": "Display all commands and their current selection",
                "command": "update-alternatives --get-selections"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "",
                "long": "--force",
                "arg": null,
                "description": "Allow replacing or dropping any real file that is installed where an alternative link has to be installed or removed."
            },
            {
                "flag": "",
                "long": "--skip-auto",
                "arg": null,
                "description": "Skip configuration prompt for alternatives which are properly configured in automatic mode. This option is only relevant with --config or --all."
            },
            {
                "flag": "",
                "long": "--quiet",
                "arg": null,
                "description": "Do not generate any comments unless errors occur."
            },
            {
                "flag": "",
                "long": "--verbose",
                "arg": null,
                "description": "Generate more comments about what is being done."
            },
            {
                "flag": "",
                "long": "--debug",
                "arg": null,
                "description": "Generate even more comments, helpful for debugging, about what is being done (since version 1.19.3)."
            }
        ],
        "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 manpage.",
            "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"
        ],
        "see_also": [
            {
                "name": "ln",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/ln/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 69,
                "subsections": []
            },
            {
                "name": "TERMINOLOGY",
                "lines": 40,
                "subsections": []
            },
            {
                "name": "COMMANDS",
                "lines": 35,
                "subsections": [
                    {
                        "name": "--all",
                        "lines": 16,
                        "long": "--all"
                    },
                    {
                        "name": "--get-selections",
                        "lines": 6,
                        "long": "--get-selections"
                    },
                    {
                        "name": "--set-selections",
                        "lines": 14,
                        "long": "--set-selections"
                    },
                    {
                        "name": "--help",
                        "lines": 2,
                        "long": "--help"
                    },
                    {
                        "name": "--version",
                        "lines": 2,
                        "long": "--version"
                    }
                ]
            },
            {
                "name": "OPTIONS",
                "lines": 20,
                "subsections": [
                    {
                        "name": "--force",
                        "lines": 3,
                        "long": "--force"
                    },
                    {
                        "name": "--skip-auto",
                        "lines": 3,
                        "long": "--skip-auto"
                    },
                    {
                        "name": "--quiet",
                        "lines": 2,
                        "long": "--quiet"
                    },
                    {
                        "name": "--verbose",
                        "lines": 2,
                        "long": "--verbose"
                    },
                    {
                        "name": "--debug",
                        "lines": 3,
                        "long": "--debug"
                    }
                ]
            },
            {
                "name": "EXIT STATUS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "ENVIRONMENT",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "FILES",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "QUERY FORMAT",
                "lines": 40,
                "subsections": [
                    {
                        "name": "Example",
                        "lines": 27
                    }
                ]
            },
            {
                "name": "DIAGNOSTICS",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "update-alternatives - maintain symbolic links determining default commands\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "update-alternatives [option...] command\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "update-alternatives creates, removes, maintains and displays information about the symbolic\nlinks comprising the Debian alternatives system.\n\nIt is possible for several programs fulfilling the same or similar functions to be installed\non a single system at the same time.  For example, many systems have several text editors\ninstalled at once.  This gives choice to the users of a system, allowing each to use a\ndifferent editor, if desired, but makes it difficult for a program to make a good choice for\nan editor to invoke if the user has not specified a particular preference.\n\nDebian's alternatives system aims to solve this problem.  A generic name in the filesystem is\nshared by all files providing interchangeable functionality.  The alternatives system and the\nsystem administrator together determine which actual file is referenced by this generic name.\nFor example, if the text editors ed(1) and nvi(1) are both installed on the system, the\nalternatives system will cause the generic name /usr/bin/editor to refer to /usr/bin/nvi by\ndefault. The system administrator can override this and cause it to refer to /usr/bin/ed\ninstead, and the alternatives system will not alter this setting until explicitly requested\nto do so.\n\nThe generic name is not a direct symbolic link to the selected alternative.  Instead, it is a\nsymbolic link to a name in the alternatives directory, which in turn is a symbolic link to\nthe actual file referenced.  This is done so that the system administrator's changes can be\nconfined within the /etc directory: the FHS (q.v.) gives reasons why this is a Good Thing.\n\nWhen each package providing a file with a particular functionality is installed, changed or\nremoved, update-alternatives is called to update information about that file in the\nalternatives system.  update-alternatives is usually called from the following Debian package\nmaintainer scripts, postinst (configure) to install the alternative and from prerm and postrm\n(remove) to remove the alternative.  Note: in most (if not all) cases no other maintainer\nscript actions should call update-alternatives, in particular neither of upgrade nor\ndisappear, as any other such action can lose the manual state of an alternative, or make the\nalternative temporarily flip-flop, or completely switch when several of them have the same\npriority.\n\nIt is often useful for a number of alternatives to be synchronized, so that they are changed\nas a group; for example, when several versions of the vi(1) editor are installed, the man\npage referenced by /usr/share/man/man1/vi.1 should correspond to the executable referenced by\n/usr/bin/vi.  update-alternatives handles this by means of master and slave links; when the\nmaster is changed, any associated slaves are changed too.  A master link and its associated\nslaves make up a link group.\n\nEach link group is, at any given time, in one of two modes: automatic or manual.  When a\ngroup is in automatic mode, the alternatives system will automatically decide, as packages\nare installed and removed, whether and how to update the links.  In manual mode, the\nalternatives system will retain the choice of the administrator and avoid changing the links\n(except when something is broken).\n\nLink groups are in automatic mode when they are first introduced to the system.  If the\nsystem administrator makes changes to the system's automatic settings, this will be noticed\nthe next time update-alternatives is run on the changed link's group, and the group will\nautomatically be switched to manual mode.\n\nEach alternative has a priority associated with it.  When a link group is in automatic mode,\nthe alternatives pointed to by members of the group will be those which have the highest\npriority.\n\nWhen using the --config option, update-alternatives will list all of the choices for the link\ngroup of which given name is the master alternative name.  The current choice is marked with\na ‘*’.  You will then be prompted for your choice regarding this link group.  Depending on\nthe choice made, the link group might no longer be in auto mode. You will need to use the\n--auto option in order to return to the automatic mode (or you can rerun --config and select\nthe entry marked as automatic).\n\nIf you want to configure non-interactively you can use the --set option instead (see below).\n\nDifferent packages providing the same file need to do so cooperatively.  In other words, the\nusage of update-alternatives is mandatory for all involved packages in such case. It is not\npossible to override some file in a package that does not employ the update-alternatives\nmechanism.\n",
                "subsections": []
            },
            "TERMINOLOGY": {
                "content": "Since the activities of update-alternatives are quite involved, some specific terms will help\nto explain its operation.\n\ngeneric name (or alternative link)\nA name, like /usr/bin/editor, which refers, via the alternatives system, to one of a\nnumber of files of similar function.\n\nalternative name\nThe name of a symbolic link in the alternatives directory.\n\nalternative (or alternative path)\nThe name of a specific file in the filesystem, which may be made accessible via a generic\nname using the alternatives system.\n\nalternatives directory\nA directory, by default /etc/alternatives, containing the symlinks.\n\nadministrative directory\nA directory, by default /var/lib/dpkg/alternatives, containing update-alternatives' state\ninformation.\n\nlink group\nA set of related symlinks, intended to be updated as a group.\n\nmaster link\nThe alternative link in a link group which determines how the other links in the group\nare configured.\n\nslave link\nAn alternative link in a link group which is controlled by the setting of the master\nlink.\n\nautomatic mode\nWhen a link group is in automatic mode, the alternatives system ensures that the links in\nthe group point to the highest priority alternative appropriate for the group.\n\nmanual mode\nWhen a link group is in manual mode, the alternatives system will not make any changes to\nthe system administrator's settings.\n",
                "subsections": []
            },
            "COMMANDS": {
                "content": "--install link name path priority [--slave link name path]...\nAdd a group of alternatives to the system.  link is the generic name for the master link,\nname is the name of its symlink in the alternatives directory, and path is the\nalternative being introduced for the master link.  The arguments after --slave are the\ngeneric name, symlink name in the alternatives directory and the alternative path for a\nslave link.  Zero or more --slave options, each followed by three arguments, may be\nspecified. Note that the master alternative must exist or the call will fail. However if\na slave alternative doesn't exist, the corresponding slave alternative link will simply\nnot be installed (a warning will still be displayed). If some real file is installed\nwhere an alternative link has to be installed, it is kept unless --force is used.\n\nIf the alternative name specified exists already in the alternatives system's records,\nthe information supplied will be added as a new set of alternatives for the group.\nOtherwise, a new group, set to automatic mode, will be added with this information.  If\nthe group is in automatic mode, and the newly added alternatives' priority is higher than\nany other installed alternatives for this group, the symlinks will be updated to point to\nthe newly added alternatives.\n\n--set name path\nSet the program path as alternative for name.  This is equivalent to --config but is non-\ninteractive and thus scriptable.\n\n--remove name path\nRemove an alternative and all of its associated slave links.  name is a name in the\nalternatives directory, and path is an absolute filename to which name could be linked.\nIf name is indeed linked to path, name will be updated to point to another appropriate\nalternative (and the group is put back in automatic mode), or removed if there is no such\nalternative left.  Associated slave links will be updated or removed, correspondingly.\nIf the link is not currently pointing to path, no links are changed; only the information\nabout the alternative is removed.\n\n--remove-all name\nRemove all alternatives and all of their associated slave links.  name is a name in the\nalternatives directory.\n",
                "subsections": [
                    {
                        "name": "--all",
                        "content": "Call --config on all alternatives. It can be usefully combined with --skip-auto to review\nand configure all alternatives which are not configured in automatic mode. Broken\nalternatives are also displayed.  Thus a simple way to fix all broken alternatives is to\ncall yes '' | update-alternatives --force --all.\n\n--auto name\nSwitch the link group behind the alternative for name to automatic mode.  In the process,\nthe master symlink and its slaves are updated to point to the highest priority installed\nalternatives.\n\n--display name\nDisplay information about the link group.  Information displayed includes the group's\nmode (auto or manual), the master and slave links, which alternative the master link\ncurrently points to, what other alternatives are available (and their corresponding slave\nalternatives), and the highest priority alternative currently installed.\n",
                        "long": "--all"
                    },
                    {
                        "name": "--get-selections",
                        "content": "List all master alternative names (those controlling a link group) and their status\n(since version 1.15.0).  Each line contains up to 3 fields (separated by one or more\nspaces). The first field is the alternative name, the second one is the status (either\nauto or manual), and the last one contains the current choice in the alternative (beware:\nit's a filename and thus might contain spaces).\n",
                        "long": "--get-selections"
                    },
                    {
                        "name": "--set-selections",
                        "content": "Read configuration of alternatives on standard input in the format generated by\n--get-selections and reconfigure them accordingly (since version 1.15.0).\n\n--query name\nDisplay information about the link group like --display does, but in a machine parseable\nway (since version 1.15.0, see section QUERY FORMAT below).\n\n--list name\nDisplay all targets of the link group.\n\n--config name\nShow available alternatives for a link group and allow the user to interactively select\nwhich one to use. The link group is updated.\n",
                        "long": "--set-selections"
                    },
                    {
                        "name": "--help",
                        "content": "Show the usage message and exit.\n",
                        "long": "--help"
                    },
                    {
                        "name": "--version",
                        "content": "Show the version and exit.\n",
                        "long": "--version"
                    }
                ]
            },
            "OPTIONS": {
                "content": "--altdir directory\nSpecifies the alternatives directory, when this is to be different from the default.\nDefaults to «/etc/alternatives».\n\n--admindir directory\nSpecifies the administrative directory, when this is to be different from the default.\nDefaults to «/var/lib/dpkg/alternatives»\n\n--instdir directory\nSpecifies the installation directory where alternatives links will be created (since\nversion 1.20.1).  Defaults to «».\n\n--root directory\nSpecifies the root directory (since version 1.20.1).  This also sets the alternatives,\ninstallation and administrative directories to match.  Defaults to «».\n\n--log file\nSpecifies the log file (since version 1.15.0), when this is to be different from the\ndefault (/var/log/alternatives.log).\n",
                "subsections": [
                    {
                        "name": "--force",
                        "content": "Allow replacing or dropping any real file that is installed where an alternative link has\nto be installed or removed.\n",
                        "long": "--force"
                    },
                    {
                        "name": "--skip-auto",
                        "content": "Skip configuration prompt for alternatives which are properly configured in automatic\nmode. This option is only relevant with --config or --all.\n",
                        "long": "--skip-auto"
                    },
                    {
                        "name": "--quiet",
                        "content": "Do not generate any comments unless errors occur.\n",
                        "long": "--quiet"
                    },
                    {
                        "name": "--verbose",
                        "content": "Generate more comments about what is being done.\n",
                        "long": "--verbose"
                    },
                    {
                        "name": "--debug",
                        "content": "Generate even more comments, helpful for debugging, about what is being done (since\nversion 1.19.3).\n",
                        "long": "--debug"
                    }
                ]
            },
            "EXIT STATUS": {
                "content": "0   The requested action was successfully performed.\n\n2   Problems were encountered whilst parsing the command line or performing the action.\n",
                "subsections": []
            },
            "ENVIRONMENT": {
                "content": "DPKGADMINDIR\nIf set and the --admindir option has not been specified, it will be used as the base\nadministrative directory.\n",
                "subsections": []
            },
            "FILES": {
                "content": "/etc/alternatives/\nThe default alternatives directory.  Can be overridden by the --altdir option.\n\n/var/lib/dpkg/alternatives/\nThe default administration directory.  Can be overridden by the --admindir option.\n",
                "subsections": []
            },
            "QUERY FORMAT": {
                "content": "The --query format is using an RFC822-like flat format. It's made of n + 1 blocks where n is\nthe number of alternatives available in the queried link group. The first block contains the\nfollowing fields:\n\nName: name\nThe alternative name in the alternative directory.\n\nLink: link\nThe generic name of the alternative.\n\nSlaves: list-of-slaves\nWhen this field is present, the next lines hold all slave links associated to the master\nlink of the alternative. There is one slave per line. Each line contains one space, the\ngeneric name of the slave alternative, another space, and the path to the slave link.\n\nStatus: status\nThe status of the alternative (auto or manual).\n\nBest: best-choice\nThe path of the best alternative for this link group. Not present if there is no\nalternatives available.\n\nValue: currently-selected-alternative\nThe path of the currently selected alternative. It can also take the magic value none. It\nis used if the link doesn't exist.\n\nThe other blocks describe the available alternatives in the queried link group:\n\nAlternative: path-of-this-alternative\nPath to this block's alternative.\n\nPriority: priority-value\nValue of the priority of this alternative.\n\nSlaves: list-of-slaves\nWhen this field is present, the next lines hold all slave alternatives associated to the\nmaster link of the alternative. There is one slave per line. Each line contains one\nspace, the generic name of the slave alternative, another space, and the path to the\nslave alternative.\n",
                "subsections": [
                    {
                        "name": "Example",
                        "content": "$ update-alternatives --query editor\nName: editor\nLink: /usr/bin/editor\nSlaves:\neditor.1.gz /usr/share/man/man1/editor.1.gz\neditor.fr.1.gz /usr/share/man/fr/man1/editor.1.gz\neditor.it.1.gz /usr/share/man/it/man1/editor.1.gz\neditor.pl.1.gz /usr/share/man/pl/man1/editor.1.gz\neditor.ru.1.gz /usr/share/man/ru/man1/editor.1.gz\nStatus: auto\nBest: /usr/bin/vim.basic\nValue: /usr/bin/vim.basic\n\nAlternative: /bin/ed\nPriority: -100\nSlaves:\neditor.1.gz /usr/share/man/man1/ed.1.gz\n\nAlternative: /usr/bin/vim.basic\nPriority: 50\nSlaves:\neditor.1.gz /usr/share/man/man1/vim.1.gz\neditor.fr.1.gz /usr/share/man/fr/man1/vim.1.gz\neditor.it.1.gz /usr/share/man/it/man1/vim.1.gz\neditor.pl.1.gz /usr/share/man/pl/man1/vim.1.gz\neditor.ru.1.gz /usr/share/man/ru/man1/vim.1.gz\n"
                    }
                ]
            },
            "DIAGNOSTICS": {
                "content": "With --verbose update-alternatives chatters incessantly about its activities on its standard\noutput channel.  If problems occur, update-alternatives outputs error messages on its\nstandard error channel and returns an exit status of 2.  These diagnostics should be self-\nexplanatory; if you do not find them so, please report this as a bug.\n",
                "subsections": []
            },
            "EXAMPLES": {
                "content": "There are several packages which provide a text editor compatible with vi, for example nvi\nand vim. Which one is used is controlled by the link group vi, which includes links for the\nprogram itself and the associated manpage.\n\nTo display the available packages which provide vi and the current setting for it, use the\n--display action:\n\nupdate-alternatives --display vi\n\nTo choose a particular vi implementation, use this command as root and then select a number\nfrom the list:\n\nupdate-alternatives --config vi\n\nTo go back to having the vi implementation chosen automatically, do this as root:\n\nupdate-alternatives --auto vi\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "ln(1), FHS (the Filesystem Hierarchy Standard).\n\n\n\n1.21.1                                       2025-09-09                       update-alternatives(1)",
                "subsections": []
            }
        }
    }
}