Help us understand the problem. What is going on with this article?

update-alternativesの使い方

More than 3 years have passed since last update.

システムで使われるプログラムのバージョン管理を行うためのupdate-alternativesの使い方。

確認

# update-alternatives --display java
java - manual mode
  link currently points to /usr/lib/jvm/default-java/bin/java
/usr/lib/jvm/default-java/bin/java - priority 1
/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java - priority 1061
  slave java.1.gz: /usr/lib/jvm/java-6-openjdk-amd64/jre/man/man1/java.1.gz
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java - priority 1051
  slave java.1.gz: /usr/lib/jvm/java-7-openjdk-amd64/jre/man/man1/java.1.gz
/usr/lib/jvm/java-8-oracle/jre/bin/java - priority 1062
  slave java.1.gz: /usr/lib/jvm/java-8-oracle/man/man1/java.1.gz
Current 'best' version is '/usr/lib/jvm/java-8-oracle/jre/bin/java'.

変更

# update-alternatives --config java
There are 4 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-8-oracle/jre/bin/java          1062      auto mode
* 1            /usr/lib/jvm/default-java/bin/java               1         manual mode
  2            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  3            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1051      manual mode
  4            /usr/lib/jvm/java-8-oracle/jre/bin/java          1062      manual mode

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

autoモード

プライオリティ値で自動的に使うものを選択するautoモードへの切り替え

# update-alternatives --auto vi

まずマニュアルで2番を選択してみる

# update-alternatives --config vi
There are 2 choices for the alternative vi (providing /usr/bin/vi).

  Selection    Path                Priority   Status
------------------------------------------------------------
  0            /usr/bin/vim.basic   30        auto mode
  1            /usr/bin/vim.basic   30        manual mode
* 2            /usr/bin/vim.tiny    10        manual mode

Press enter to keep the current choice[*], or type selection number: 
root@stg-jenkins-n01:/usr/bin# update-alternatives --auto vi
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode.

その後autoモードにすると、priortyで選ばれているのがわかる

# update-alternatives --config vi
There are 2 choices for the alternative vi (providing /usr/bin/vi).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/vim.basic   30        auto mode
  1            /usr/bin/vim.basic   30        manual mode
  2            /usr/bin/vim.tiny    10        manual mode
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away