Ubuntuでupdate-alternativesコマンド(バージョン切替コマンド)

2650 ワード

Ubuntuでupdate-alternativesコマンド(バージョン切替コマンド)
1.update-alternativesコマンドオプション紹介:display、install、remove、config
2.displayコマンド:(コマンドリンク情報を表示)
# update-alternatives --display name(    )
sean@sean:~/work/p53/build$ update-alternatives --display automake 
automake - auto mode
  link best version is /usr/bin/automake-1.15
  link currently points to /usr/bin/automake-1.15
  link automake is /usr/bin/automake
  slave aclocal is /usr/bin/aclocal
  slave aclocal.1.gz is /usr/share/man/man1/aclocal.1.gz
  slave automake.1.gz is /usr/share/man/man1/automake.1.gz
/usr/bin/automake-1.11 - priority 29
  slave aclocal: /usr/bin/aclocal-1.11
  slave aclocal.1.gz: /usr/share/man/man1/aclocal-1.11.1.gz
  slave automake.1.gz: /usr/share/man/man1/automake-1.11.1.gz
/usr/bin/automake-1.15 - priority 33
  slave aclocal: /usr/bin/aclocal-1.15
  slave aclocal.1.gz: /usr/share/man/man1/aclocal-1.15.1.gz
  slave automake.1.gz: /usr/share/man/man1/automake-1.15.1.gz
sean@sean:~/work/p53/build$ 


3.installコマンド:(コマンドリンクを追加)
# update-alternatives --install link name path priority
# link ->       name ->       
# path ->       priority ->    

$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.7 100
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50

$ update-alternatives --display gcc
gcc - auto mode
  link currently points to /usr/bin/gcc-4.7
/usr/bin/gcc-4.7 - priority 100
/usr/bin/gcc-4.8 - priority 50
Current 'best' version is '/usr/bin/gcc-4.7'.

4.removeコマンド:(コマンドリンクを削除)
# update-alternatives --remove name path
# name, path   install    

$ sudo update-alternatives --remove g++ /usr/bin/g++-4.8

$ update-alternatives --display gcc
gcc - auto mode
  link currently points to /usr/bin/gcc-4.7
/usr/bin/gcc-4.7 - priority 100
Current 'best' version is '/usr/bin/gcc-4.7'.

5.configコマンド:(コマンドリンクの構成)
sean@sean:~/work/p53/build$ update-alternatives --config automake 
There are 2 choices for the alternative automake (providing /usr/bin/automake).

  Selection    Path                    Priority   Status
------------------------------------------------------------
* 0            /usr/bin/automake-1.15   33        auto mode
  1            /usr/bin/automake-1.11   29        manual mode
  2            /usr/bin/automake-1.15   33        manual mode

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

  • autoとmanualモード変換
  • # update-alternatives --auto name
    $ update-alternatives --auto gcc