update-alternatives是ubuntu系統中專門維護系統命令鏈接符的工具,通過它可以很方便的設置系統默認使用哪個命令、哪個軟件版本,比如,我們在系統中同時安裝了python2.7和python3.6兩個版本,而我們又希望系統默認使用的是python3.6,那怎么辦呢?通過update-alternatives就可以很方便的實現了。
1.更新替代列表(管理員權限下)
命令格式:update-alternatives --install <link> <name> <path> <priority>
<link> is the symlink pointing to /etc/alternatives/<name>.
(e.g. /usr/bin/pager)
<name> is the master name for this link group.
(e.g. pager)
<path> is the location of one of the alternative target files.
(e.g. /usr/bin/less)
<priority> is an integer; options with higher numbers have higher priority in
automatic mode.
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
2、查看替代列表:
update-alternatives --list python
3、切換:
update-alternatives --config python