知乎專欄 | 多維度架構 | 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者” |
[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