知乎专栏 |
[root@localhost ~]# alternatives --list libwbclient.so.0.14-64 auto /usr/lib64/samba/wbclient/libwbclient.so.0.14 ld auto /usr/bin/ld.bfd cups_backend_smb auto /usr/bin/smbspool mta auto /usr/sbin/sendmail.postfix libnssckbi.so.x86_64 auto /usr/lib64/pkcs11/p11-kit-trust.so jre_1.8.0 auto /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre jre_1.8.0_openjdk auto /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64 pgsql-ld-conf auto /usr/pgsql-11/share/postgresql-11-libs.conf dockerd auto /usr/bin/dockerd-ce java auto /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/bin/java jre_openjdk auto /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre jre_11 auto /usr/lib/jvm/java-11-openjdk-11.0.3.7-0.el7_6.x86_64 jre_11_openjdk auto /usr/lib/jvm/jre-11-openjdk-11.0.3.7-0.el7_6.x86_64
[root@localhost ~]# alternatives --config java There are 3 programs which provide 'java'. Selection Command ----------------------------------------------- 1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64/jre/bin/java) *+ 2 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/bin/java) 3 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.3.7-0.el7_6.x86_64/bin/java) Enter to keep the current selection[+], or type selection number: 3
输入数字 3,切换到 Java 11
[root@localhost ~]# java -version openjdk version "11.0.3" 2019-04-16 LTS OpenJDK Runtime Environment 18.9 (build 11.0.3+7-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.3+7-LTS, mixed mode, sharing)
下面 nodejs 是编译版本,我们需要使用 alternatives 来管理版本
alternatives --install /usr/local/bin/node node /srv/node-v12.3.1/bin/node 100
查看 node
[root@localhost ~]# alternatives --display node node - status is auto. link currently points to /srv/node-v12.3.1/bin/node /srv/node-v12.3.1/bin/node - priority 100 Current `best' version is /srv/node-v12.3.1/bin/node.
删除 node
[root@localhost ~]# alternatives --remove node /srv/node-v12.3.1/bin/node [root@localhost ~]# alternatives --display node
update-alternatives --config editor
root@production:~# update-alternatives --config editor There are 4 choices for the alternative editor (providing /usr/bin/editor). Selection Path Priority Status ------------------------------------------------------------ 0 /bin/nano 40 auto mode 1 /bin/ed -100 manual mode 2 /bin/nano 40 manual mode 3 /usr/bin/vim.basic 30 manual mode * 4 /usr/bin/vim.tiny 10 manual mode Press <enter> to keep the current choice[*], or type selection number: