Alternatives command usage
Alternatives is a powerful command in Linux. It can only be executed under the root permission. If the system has several command functions that are similar 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. How can I ignore the installation path and use the desired Java version according to my own meaning?
Here we will show you one by one.
Execute the command line of alternatives as follows:
[Root @ localhost 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>
Where,
Install
Link is a symbolic link.
Name indicates the identifier.
PATH is the path of the execution File
Priority indicates the priority.
Taking Java installation as an example, my fedora 8 comes with two Java versions, respectively:
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 directory"
[Root @ localhost test] # alternatives -- install/usr/bin/Java/tools/JDK/bin/Java 3
[Root @ localhost 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 directory"
[Root @ localhost test] # alternatives -- install/usr/bin/Java/tools/jdk6/bin/Java 4
[Root @ localhost 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.