22
33

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

update-alternativesの使い方

Posted at

システムで使われるプログラムのバージョン管理を行うための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
22
33
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
33

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?