理解update-alternatives on Ubuntu

  • Symbolic links

Ubuntu keeps track of the default programs by maintaining a list of symbolic links, under /etc/alternatives directory. Each entry here is a shortcut points to the actual program, which may have more than one option.

  • update-alternatives

# List All Entries of Alternatives
update-alternatives --get-selections
# List All Alternatives of an Entry
update-alternatives --list python
# Set Alternatives for an Entry
update-alternatives --config python # interactive choice
update-alternatives --set python /usr/bin/python

上述操作可能出现错误:update-alternatives: error: no alternatives for python

需要使用update-alternatives --install

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
  • 软连接

sudo ln -s /path /usr/bin/python
  • References

  1. Changing the Default Program with update alternatives
  2. ubuntu manuals
  3. 【Python】Ubuntu修改默认Python版本

你可能感兴趣的:(#,Linux)