什么是linux中的update-alternatives命令,它有什么用?

时间:2017-10-23 13:34:47

标签: java linux

在Linux中安装java时有一些update-alternatives命令的用法,因为我是Linux环境的新手,我想知道这个命令的作用以及它的用途

>>sudo update-alternatives --install /usr/bin/java java /usr/lib/java/JDk.../bin/java

1 个答案:

答案 0 :(得分:3)

基本上它告诉你的机器使用Jave JDK的替代品而不是默认的那个,在Linux系统中,它是OpenJDK。

手册页的摘要比我写的任何答案都要好:

  

update-alternatives创建,删除,维护和显示有关符号链接的信息          Debian替代系统。

   It is possible for several programs fulfilling the same or similar functions to be installed on a single  sys‐
   tem  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 prefer‐
   ence.

   Debian's alternatives system aims to solve this problem.  A generic name in the filesystem is  shared  by  all
   files  providing interchangeable functionality.  The alternatives system and the system administrator together
   determine which actual file is referenced by this generic name.  For example, if the text  editors  ed(1)  and
   nvi(1)  are  both installed on the system, the alternatives system will cause the generic name /usr/bin/editor
   to refer to /usr/bin/nvi by default. The system administrator can override this  and  cause  it  to  refer  to
   /usr/bin/ed  instead, and the alternatives system will not alter this setting until explicitly requested to do
   so.

使用--install你指定了一个链接,“/ usr / bin / java”一个名字“java”和一个路径“/ usr / lib / java / JDK ....”你添加了一组替代品系统。 link是主链接的通用名称,name是alternative目录中其符号链接的名称,path是为主链接引入的替代方法。

我希望足够清楚,这里有一个post regarding java alternatives

对于完整的使用列表,我建议查看相同的手册页,在OS shell上键入man update-alternatives;