A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
-bash/zsh: update-alternatives: command not found # Windows (WSL2) sudo apt-get install dpkg # Debian apt-get install dpkg # Ubuntu apt-get install dpkg # Alpine apk add dpkg # Kali Linux apt-get install dpkg # CentOS yum install chkconfig # Fedora dnf install chkconfig # OS X brew install dpkg # Raspbian apt-get install dpkg # Dockerfile dockerfile.run/update-alternatives # Docker docker run cmd.cat/update-alternatives update-alternatives
update-alternatives 创建、删除、维护和显示信息关于包含 Debian 替代系统的符号链接。update-alternatives 适用于在多个同类型命令中进行切换的一个脚本。
alternatives [options] --install link name path priority [--slave link name path]... [--initscript service] [--family name] alternatives [options] --remove name path alternatives [options] --set name path alternatives [options] --auto name alternatives [options] --display name alternatives [options] --config name alternatives [options] --list name
COMMON OPTIONS --verbose Generate more comments about what alternatives is doing. --quiet Don't generate any comments unless errors occur. This option is not yet implemented. --test Don't actually do anything, just say what would be done. This option is not yet implemented. --help Give some usage information (and say which version of alternatives this is). --version Tell which version of alternatives this is (and give some usage information). --altdir directory Specifies the alternatives directory, when this is to be different from the default. --admindir directory Specifies the administrative directory, when this is to be different from the default. ACTIONS --install link name path priority [--slave slink sname spath] [--initscript service]... Add a group of alternatives to the system. name is the generic name for the master link, link is the name of its symlink, path is the alternative being introduced for the master link, and priority is the priority of the alternatives group. Higher priorities take precendence if no alternative is manually selected. sname, slink and spath are the generic name, symlink name and alternative for a slave link, and service is the name of any associated initscript for the alternative. NOTE: --initscript and --family are a Red Hat Linux specific options. Zero or more --slave options, each followed by three arguments, may be specified. If the master symlink specified 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. If --initscript is used, the alternatives system will manage the initscript associated with the alternative via chkconfig, registering and unregistering the init script depending on which alternative is active. NOTE: --initscript is a Red Hat Linux specific option. --family can be used to group similar alternatives. If the group is in manual mode and the alternative currently used is removed, alternatives will try to change links to different one with same family and highest priority. NOTE: --family is a Red Hat Linux specific option. --remove name path Remove an alternative and all of its associated slave links. name is a name in the alternatives directory, and path is an absolute filename to which name could be linked. If name is indeed linked to path, name will be updated to point to another appropriate alternative, 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 to path, no links are changed; only the information about the alternative is removed. --set name path The symbolic link and slaves for link group name set to those configured for path, and the link group is set to manual mode. This option is not in the original Debian implementation. --config name Present the user with a configuration menu for choosing the master link and slaves for link group name. Once chosen, the link group is set to manual mode. --auto name Switch the master symlink name to automatic mode. In the process, this symlink and its slaves are updated to point to the highest priority installed alternatives. --display name Display information about the link group of which name is the master link. Information displayed includes the group's mode (auto or manual), which alternative the symlink currently points to, what other alternatives are available (and their corresponding slave alternatives), and the highest priority alternative currently installed. --list Display information about all link groups. FILES /etc/alternatives/ The default alternatives directory. Can be overridden by the --altdir option. /var/lib/alternatives/ The default administration directory. Can be overridden by the --admindir option. EXIT STATUS 0 The requested action was successfully performed. 2 Problems were encountered whilst parsing the command line or performing the action.
update-alternatives 添加符号链接:
sudo update-alternatives --install path/to/symlink command_name path/to/command_binary priority
update-alternatives 为 `java` 配置一个符号链接:
sudo update-alternatives --config java
update-alternatives 删除符号链接:
sudo update-alternatives --remove java /opt/java/jdk1.8.0_102/bin/java
update-alternatives 显示有关指定命令的信息:
update-alternatives --display java
update-alternatives 显示所有命令及其当前选择:
update-alternatives --get-selections