update-alternatives 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.
该命令是解决单系统上多个版本管理切换的解决方案!简单说也就是一个符号链接的管理程序
下面是基本的用法:
用法:update-alternatives [<选项> ...] <命令>
命令:
--install <链接> <名称> <路径> <优先级>
[--slave <链接> <名称> <路径>] ...
在系统中加入一组候选项。
--remove <名称> <路径> 从 <名称> 替换组中去除 <路径> 项。
--remove-all <名称> 从替换系统中删除 <名称> 替换组。
--auto <名称> 将 <名称> 的主链接切换到自动模式。
--display <名称> 显示关于 <名称> 替换组的信息。
--query <名称> 机器可读版的 --display <名称>.
--list <名称> 列出 <名称> 替换组中所有的可用候选项。
--get-selections 列出主要候选项名称以及它们的状态。
--set-selections 从标准输入中读入候选项的状态。
--config <名称> 列出 <名称> 替换组中的可选项,并就使用其中
哪一个,征询用户的意见。
--set <名称> <路径> 将 <路径> 设置为 <名称> 的候选项。
--all 对所有可选项一一调用 --config 命令。
<链接> 是指向 /etc/alternatives/<名称> 的符号链接。
(如 /usr/bin/pager)
<名称> 是该链接替换组的主控名。
(如 pager)
<路径> 是候选项目标文件的位置。
(如 /usr/bin/less)
<优先级> 是一个整数,在自动模式下,这个数字越高的选项,其优先级也就越高。
选项:
--altdir <目录> 改变候选项目录。
--admindir <目录> 设置 statoverride 文件的目录。
--log <文件> 改变日志文件。
--force 就算没有通过自检,也强制执行操作。
--skip-auto 在自动模式中跳过设置正确候选项的提示
(只与 --config 有关)
--quiet 安静模式,输出尽可能少的信息。不显示输出信息。
--verbose 启用详细输出。
--debug 调试输出,信息更多。
--help 显示本帮助信息。
--version 显示版本信息。
应用场景很多,比如Python有2和3的版本,甚至3也有很多3.x的版本,如果想在一个系统上安装多个环境而且自由切换,这个命令就可以帮助你实现这种功能!还有jdk版本等等都可以借助其帮助管理!
具体可以参考另外一篇博客!
如果有什么问题欢迎下方留言,如果帮到你请记得点赞,感谢!