M BUZZ CRAZE NEWS
// general

What do the parameters in update alternatives install mean

By Emma Johnson

I need help in understanding the following parameters

"/usr/bin/java" "java" ""/usr/java/latest/bin/java" 1

in the following command.

update-alternatives --install "/usr/bin/java" "java" ""/usr/java/latest/bin/java" 1

I understand you are telling your system to have another java version it can use.

But:

Why is there a "java" in quotes, and what is the purpose of the 1?

3

4 Answers

Why is there a "java" in quotes

To quote the Ubuntu man page this text is the "name," which "is the name of its symlink in the alternatives directory." In other words this is so when you type java (or whatever text you choose) in the terminal it knows you are looking for this particular link.

what is the purpose of the 1?

Again from the man page this is the "priority" which is used for the following purpose - "when a link group is in automatic mode, the alternatives system ensures that the links in the group point to the highest priority alternative appropriate for the group." In other words if a decision needs to be made as to which link is used, the numerically higher value wins out. I suspect however it may be inconsequential, by using update-alternatives you are switching the default from "automatic" to "manual" in which case I don't think it applies. But I am no expert.

There is a useful post from William DeMeo for background.

from :

update-alternatives --install link name path priority

Will update answer later with explanation of "alternatives" in linux.

If you run command :

$man update-alternatives

Output:

alternatives [options] --install link name path priority [--slave link name path]... [--initscript service]

The java means that want to update java with a priority on either 1, 2, 3, etc.

You need to mention the path and all parameters in the given order above.

What previous answers are missing is an actual explanation of the arguments, which is also included in man:

man update-alternatives
--install link name path priority [--slave link name path]...

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. The arguments after --slave are the generic name, symlink name in the alternatives directory and the alternative path for a slave link. Zero or more --slave options, each followed by three arguments, may be specified. Note that the master alternative must exist or the call will fail. However if a slave alternative doesn't exist, the corresponding slave alternative link will simply not be installed (a warning will still be displayed). If some real file is installed where an alternative link has to be installed, it is kept unless --force is used.

If the alternative name specified exists already in the alternatives system's records, the information supplied will be added as a new set of alternatives for the group. Otherwise, a new group, set to automatic mode, will be added with this information. If the group is in automatic mode, and the newly added alternatives' priority is higher than any other installed alternatives for this group, the symlinks will be updated to point to the newly added alternatives.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy