Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is update-alternatives command in linux and what is the use of it?

Tags:

java

linux

while installation of java in Linux there is some usage of update-alternatives command since i am new to Linux environment i want to know what this command does and what is the use of it

>>sudo update-alternatives --install /usr/bin/java java /usr/lib/java/JDk.../bin/java
like image 406
kiran kumar Avatar asked Mar 07 '23 18:03

kiran kumar


1 Answers

Basically it says to your machine to use this alternative of Jave JDK instead of the default one, which, in Linux systems, is OpenJDK.

A brief extract from the man page is better than any answer I could write:

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.

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.

With --install you specified a link, "/usr/bin/java" a name "java" and a path "/usr/lib/java/JDK...." and you add a group of alternatives to the system. link is the generic name for the master link, name is the name of its symlink in the alternatives directory, and path is the alternative being introduced for the master link.

I hope to be clear enough, Here there is a post regarding java alternatives.

For the complete usage list I suggest to look at the same manual page, typing man update-alternatives on your OS shell;

like image 73
Fjordo Avatar answered Mar 10 '23 11:03

Fjordo