Switch software versions via update-alternatives in Ubuntu

Source: Internet
Author: User
Tags new set

Update-alternatives is a tool dedicated to maintaining the system command link in the Ubuntu system, which makes it easy to set which command the system uses by default, which software version, for example, we have both open jdk and Sun JDK Two versions installed in the system. And we want the system to use the sun JDK by default, what should we do? Through the update-alternatives can be very convenient to achieve.

sudo update-alternatives--install/usr/bin/java Java/opt/java/jdk1.6.0_27/bin/java 1062

Where 1062 is the priority after the alternative change, the priority of the new change needs to be greater than the current one, which can be viewed through update-alternatives--display java.

Now introduce several main options in the Update-alternatives command, diplay, install, remove, config;

1. The display option is the ability to view all the information for a command link group, including the linked mode (automatic or manual), link priority value, all available link commands, and so on. Use syntax: update-alternatives--display name, where name is the command link name, such as Java, execute command: Update-alternatives--display Java will appear similar to the following results

Java-auto mode

Link currently points To/opt/java/jdk1.6.0_27/bin/java

/opt/java/jdk1.6.0_27/bin/java-priority 1062

/usr/lib/jvm/java-6-openjdk/jre/bin/java-priority 1061

Slave java.1.gz:/usr/lib/jvm/java-6-openjdk/jre/man/man1/java.1.gz

Current "Best" version is '/opt/java/jdk1.6.0_27/bin/java '.

2, the Install option function is to add a new set of system command link, using the syntax: update-alternatives--install link name path priority [--slave link name path] ... Link for the system in the same function of the software's public link directory, such as/usr/bin/java (need absolute directory); The name is the command-link, such as Java, where you want to use the new command, the directory where the new software is located, and priority, which is higher than the current value when the command link already exists, because when alternative is in Auto mode, The system by default enables the link to priority high; --slave is from alternative.

Alternative has two modes: auto and manual, which are auto mode by default, because in most cases update-alternatives commands are called by Postinst (configure) or prerm (install), If you change it to manual, the installation script will not update it.

3, the Remove option function is to delete a alternative and related from alternative, using the syntax: update-alternatives--remove name path, where name and path are consistent with the install , if there are other links in the deleted link Group, the system will automatically select a priority link from the other to be the default link.

4, config option function for the existing command link to select a system default, using the syntax: update-alternatives--config name, as executed: sudo update-alternatives--config java , there will be information similar to the following:

There is 2 choices for the alternative Java (Providing/usr/bin/java).

Selection Path Priority Status

------------------------------------------------------------

* 0/opt/java/jdk1.6.0_27/bin/java 1062 Auto mode

1/opt/java/jdk1.6.0_27/bin/java 1062 Manual Mode

2/usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 Manual Mode

Press ENTER to keep the current choice[*], or type selection number:

If you want to change the manual back to Automatic mode, execute the command: update-alternatives--auto name, as

Update-alternatives--config Java

Switch software versions via update-alternatives in Ubuntu

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.