当前位置:   article > 正文

Ubuntu中update-alternatives命令(版本切换)_update-alternatives --install /usr/bin/g++ g++ /us

update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 50 update-al

1、update-alternatives 命令选项介绍:display、install、remove、config


2、display命令:(查看命令链接信息)

# update-alternatives --display name(命令名称)

$ 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'.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

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'.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

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'.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

5、config命令:(配置命令链接)

# update-alternatives --config name

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

  Selection    Path              Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-4.7   100       auto mode
  1            /usr/bin/gcc-4.7   100       manual mode
  2            /usr/bin/gcc-4.8   50        manual mode

Press enter to keep the current choice[*], or type selection number: 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

6、auto和manual模式转换
默认为auto模式,将manual模式改为auto模式:

# update-alternatives --auto name
$ update-alternatives --auto gcc
  • 1
  • 2

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/260857
推荐阅读
相关标签
  

闽ICP备14008679号