Alternatives command usage
Alternatives is a powerful command in Linux. It can only run under the root permission. If the system has several commands with similar functions but cannot be deleted at will, you can use alternatives to specify a global setting.
Alternatives is often used to install multiple versions of the same software on the same system. For example, for development purposes, I need to install JDK 1.4.2 and JDK 1.6.10 at the same time. How can I ignore the installation path and use the Java version I want according to my own meaning?
Here is how you use it.
The command line of alternatives is as follows:
[[Email protected] tools] # alternatives
Alternatives version 1.3.36-copyrights (c) 2001 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.
Usage: alternatives -- install <link> <Name> <path> <priority>
[-- Initscript <service>]
[-- Slave <link> <Name> <path>] *
Alternatives -- remove <Name> <path>
Alternatives -- Auto <Name>
Alternatives -- config <Name>
Alternatives -- display <Name>
Alternatives -- set <Name> <path>
Common options: -- verbose -- Test -- help -- usage -- version
-- Altdir <directory> -- admindir <directory>
Note:
Alternatives -- install <link> <Name> <path> <priority>
,
Install
Link is a symbolic link.
Name indicates the identifier.
PATH is the path of the running File
Priority indicates the priority.
Taking Java installation as an example, my fedora 8 comes with two Java versions, for example:
Selection command
-----------------------------------------------
* 1/usr/lib/JVM/jre-1.7.0-icedtea/bin/Java
2/usr/lib/JVM/jre-1.5.0-gcj/bin/Java
I installed Java version "1.4.2 _ 19" in the/tools/JDK folder"
[[Email protected] Test] # alternatives -- install/usr/bin/Java/tools/JDK/bin/Java 3
[[Email protected] Test] # alternatives -- config Java
There are 3 programs which provide 'java '.
Selection command
-----------------------------------------------
* + 1/usr/lib/JVM/jre-1.7.0-icedtea/bin/Java
2/usr/lib/JVM/jre-1.5.0-gcj/bin/Java
3/tools/JDK/bin/Java
Enter to keep the current selection [+], or type selection number: 3
I also installed Java version "1.6.0 _ 12" in the/tools/jdk6 folder"
[[Email protected] Test] # alternatives -- install/usr/bin/Java/tools/jdk6/bin/Java 4
[[Email protected] Test] # alternatives -- config Java
There are 4 programs which provide 'java '.
Selection command
-----------------------------------------------
* 1/usr/lib/JVM/jre-1.7.0-icedtea/bin/Java
2/usr/lib/JVM/jre-1.5.0-gcj/bin/Java
+ 3/tools/JDK/bin/Java
4/tools/jdk6/bin/Java
Enter to keep the current selection [+], or type selection number: 4
Use alternatives -- config Java to select the desired Java version number.
Alternatives command usage