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 <enter> to keep the current choice[*], or type selection number:
- auto和manual模式转换
# update-alternatives --auto name
$ update-alternatives --auto gcc