Alternatives command usage

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.