Linux中的update-alternatives命令详解

Linux中的update-alternatives命令详解

回复
  • 李高蝶用户
    [[{"txt": "Linux \u53d1\u5c55\u5230\u4eca\u5929\uff0c\u8f6f\u4ef6\u5b9a\u671f\u90fd\u4f1a\u8fdb\u884c\u5347\u7ea7\uff0c\u73b0\u5728java\u7248\u672c\u5df2\u7ecf\u5347\u7ea7\u5230JDK8.0\uff0c\u8fd8\u6709open-jdk\u5404\u79cd\u7248\u672c\u3002\u7531\u4e8e\u8f6f\u4ef6\u9700\u8981\u5b89\u88c5\u4e86\u5f88\u591ajava\u7248\u672c\uff0c\u53c8\u4e0d\u60f3\u6bcf\u6b21\u4f7f\u7528\u90fd\u53bb\u4fee\u6539\u73af\u5883\u53d8\u91cf\u3002Debian \u63d0\u4f9b\u4e86\u4e00\u79cd\u673a\u5236\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u800c update-alternatives \n\u5c31\u662f\u7528\u6765\u5b9e\u73b0\u8fd9\u79cd\u673a\u5236\u7684\u3002\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u5efa\u7acb\u5f88\u8f6f\u94fe\u63a5\uff0c\u5f53\u5207\u6362\u7248\u672c\u7684\u65f6\u5019\uff0c\u53ea\u9700\u8981\u66f4\u6539\u8f6f\u94fe\u63a5\u7684\u6307\u5411\u3002"}, {"img": ["https://exp-picture.cdn.bcebos.com/4759c1dae43b3b862fa73be4185653bbf92075d9.m2m?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1"]}], [{"txt": ["\u5de5\u5177/\u539f\u6599"]}, {"txt": "VMware Workstation 12"}, {"txt": "ubuntu-14.04-desktop-amd64"}], [{"txt": ["\u67e5\u770b\u5df2\u6709\u7684JAVA\u7248\u672c"]}, {"txt": "\u9996\u5148\u67e5\u770b\u4e0b\u672c\u5730java\u7248\u672c\uff0c\u4f7f\u7528java -versionmec@mac:~$ java -versionjava version \"1.6.0_45\"Java(TM) SE Runtime Environment (build 1.6.0_45-b06)Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)"}, {"img": ["https://exp-picture.cdn.bcebos.com/65ba880b312105613225215a08aee8d7582a6ad9.m2m?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1"]}, {"txt": "mec@mac:~$ which java\u00a0\u00a0\u00a0\u00a0\u00a0 #which java\u547d\u4ee4\u67e5\u770bjava\u547d\u4ee4\u4f7f\u7528\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4f4d\u7f6e/usr/bin/javamec@mac:~$ ll /usr/bin/java\u00a0\u00a0\u00a0\u00a0 #\u67e5\u770b\u547d\u4ee4\u7684\u94fe\u63a5\u4f4d\u7f6elrwxrwxrwx 1 root root 22\u00a0 3\u6708\u00a0 1 22:36 /usr/bin/java -> /etc/alternatives/java"}, {"img": ["https://exp-picture.cdn.bcebos.com/e996472ae3efe07829b7ab05b96c576698cf65d9.m2m?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1"]}, {"txt": "mec@mac:~$ ll /etc/alternatives/java\u00a0\u00a0\u00a0 #\u6700\u540e\u67e5\u770b\u5230java\u547d\u4ee4\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5b9e\u9645\u4f4d\u7f6elrwxrwxrwx 1 root root 39\u00a0 4\u6708 23 16:21 /etc/alternatives/java -> /usr/lib/jvm/java-6-oracle/jre/bin/java*"}, {"img": ["https://exp-picture.cdn.bcebos.com/e3d059e833e039727785cf59b5863048604356d9.m2m?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1"]}, {"txt": "update-alternatives\u6b63\u5982\u540d\u5b57\u8868\u8fbe\u7684\u610f\u601d\u4e00\u6837\uff0c\u662f\u53ef\u9009\u62e9\u7684\u66f4\u65b0\u67e5\u770b\uff0c\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u5efa\u7acb\u5f88\u8f6f\u94fe\u63a5\uff0c\u5f53\u5207\u6362\u7248\u672c\u7684\u65f6\u5019\uff0c\u53ea\u9700\u8981\u66f4\u6539\u8f6f\u94fe\u63a5\u7684\u6307\u5411\u3002sudo update-alternatives --display java\u53ef\u4ee5\u770b\u51fa\u5f53\u524djava\u547d\u4ee4\u53ea\u6709\u4e00\u4e2a\u8f6f\u94fe\u63a5\uff0c\u6307\u5411/usr/lib/jvm/java-6-oracle/jre/bin/java\uff0c\u547d\u4ee4\u7684\u6a21\u5f0f\u662f\u81ea\u52a8auto,\u8fd9\u65f6\u5019\u4f1a\u6839\u636e\u4f18\u5148\u7ea7\u5339\u914d\uff0cpriority 1\u65e2\u662f\u4f18\u5148\u7ea7\u3002"}, {"img": ["https://exp-picture.cdn.bcebos.com/31097f43d7d44831556d8214d40f822b75ee51d9.m2m?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1"]}, {"txt": "\u5217\u51fa\u4f7f\u7528java\u547d\u4ee4\u7684\u5217\u8868\uff0c\u73b0\u5728\u53ea\u6709\u4e00\u4e2a\uff0c\u6307\u51fa\u4e86\u547d\u4ee4\u7684\u6240\u5728\u4f4d\u7f6emec@mac:~$ sudo update-alternatives --listjava/usr/lib/jvm/java-6-oracle/jre/bin/java"}, {"img": ["https://exp-picture.cdn.bcebos.com/49c5d3e34b2c56ee1bf9f2bdf775e5f4fdf540d9.m2m?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1"]}], [{"txt": ["\u914d\u7f6eJAVA\u7248\u672c"]}, {"txt": "\u73b0\u5728\u5f00\u59cb\u914d\u7f6e\uff0c\u6211\u4e0b\u8f7d\u7684JDK8\u5728/home/mec/Android/jdk1.8.0_73\u3002\u4e0b\u8f7d\u8fd9\u4e2a\u5728\u8fd9\u91cc\u5c31\u4e0d\u7ec6\u8bb2\u4e86\uff0c\u4f60\u4e5f\u53ef\u4ee5\u914d\u7f6e~/.bashrc\u6216\u662f/etc/profile\u4e2d\u7684\u73af\u5883\u53d8\u91cf\u3002"}, {"img": ["https://exp-picture.cdn.bcebos.com/7d34fbf4fcf5ee0d5c48de64f96b0ce264e7bad9.m2m?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1"]}, {"txt": "\u7531sudo update-alternatives --list java\u6211\u4eec\u4e0a\u9762\u67e5\u770b\u53ea\u6709/usr/lib/jvm/java-6-oracle/jre/bin/java\u73b0\u5728\u4f7f\u7528/usr/lib/jvm/java-6-oracle/jre/bin/javasudo update-alternatives --install /usr/bin/java java /home/mec/Android/jdk1.8.0_73/bin/java 300update-alternatives\u00a0 --install link name path priority\u5176\u4e2dlink\u4e3a\u7cfb\u7edf\u4e2d\u529f\u80fd\u76f8\u540c\u8f6f\u4ef6\u7684\u516c\u5171\u94fe\u63a5\u76ee\u5f55\uff0c\u6bd4\u5982/usr/bin/java(\u9700\u7edd\u5bf9\u76ee\u5f55);name\u4e3a\u547d\u4ee4\u94fe\u63a5\u7b26\u540d\u79f0,\u5982java\u00a0path\u4e3a\u4f60\u6240\u8981\u4f7f\u7528\u65b0\u547d\u4ee4\u3001\u65b0\u8f6f\u4ef6\u7684\u6240\u5728\u76ee\u5f55\u00a0priority\u4e3a\u4f18\u5148\u7ea7\uff0c\u5f53\u547d\u4ee4\u94fe\u63a5\u5df2\u5b58\u5728\u65f6\uff0c\u9700\u9ad8\u4e8e\u5f53\u524d\u503c\uff0c\u56e0\u4e3a\u5f53alternative\u4e3a\u81ea\u52a8\u6a21\u5f0f\u65f6,\u7cfb\u7edf\u9ed8\u8ba4\u542f\u7528priority\u9ad8\u7684\u94fe\u63a5;# \u6574\u6570 \u6839\u636e\u7248\u672c\u53f7\u8bbe\u7f6e\u7684\u4f18\u5148\u7ea7\uff08\u66f4\u6539\u7684\u4f18\u5148\u7ea7\u9700\u8981\u5927\u4e8e\u5f53\u524d\u7684\uff09"}, {"img": ["https://exp-picture.cdn.bcebos.com/732a12e265e7340f08fe609035b9763e20c2b4d9.m2m?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1"]}, {"txt": "\u73b0\u5728\u4f7f\u7528sudo update-alternatives --list java\u67e5\u770b\u4e0b\u53d1\u73b0\u591a\u4e86\u4e00\u9879/home/mec/Android/jdk1.8.0_73/bin/java/usr/lib/jvm/java-6-oracle/jre/bin/java"}, {"img": ["https://exp-picture.cdn.bcebos.com/354e7a781423beb919b8557130d6e1d06ce8b3d9.m2m?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1"]}, {"txt": "sudo update-alternatives --config javaThere are 2 choices for the alternative java (providing /usr/bin/java).*\u53f7\u4ee3\u8868\u6211\u4eec\u6b63\u5728\u4f7f\u7528\u7684\u3002\u9009\u62e91\u540e\u67e5\u770bJava\u7248\u672c"}, {"img": ["https://exp-picture.cdn.bcebos.com/6ca9846186254193b96ec4b7df1bd10ff326abd9.m2m?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1"]}, {"txt": "mec@mac:~/Android/jdk1.8.0_73$ sudo update-alternatives --remove java/home/mec/Android/jdk1.8.0_73/bin/java\u00a0\u00a0\u00a0 \u79fb\u9664\u521a\u6765\u914d\u7f6e\u7684mec@mac:~/Android/jdk1.8.0_73$ java -version\u00a0\u00a0 \u6d4b\u8bd5\u4e0b\u7248\u672c\uff0c\u53d1\u73b0\u53c8\u5207\u6362\u56de\u6765\u4e861.6"}, {"img": ["https://exp-picture.cdn.bcebos.com/d04eec260d9a310e691f9d9931b842406bfea2d9.m2m?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_500%2Climit_1"]}], [{"txt": ["\u6ce8\u610f\u4e8b\u9879"]}, {"txt": "\u4e00\u5b9a\u8981\u4e0b\u8f7d\u597dJDK."}, {"txt": "\u642d\u5efa\u597dlinux\u73af\u5883"}]]
    2024-11-25
    1楼
    回复

参与评论

游客评论不支持回复他人评论内容,如需回复他人评论内容请