不使用任何参数运行update-alternatives命令, 则显示命令的帮助
blueice:~# update-alternatives update-alternatives: need --display, --config, --set, --install, --remove, --all, --remove-all or --auto Usage: update-alternatives [ |
update-alternatives --list
blueice:~# update-alternatives --list java /usr/bin/gij-wrapper-4.0 /usr/bin/gij-wrapper-4.1 /usr/lib/jvm/java-gcj/jre/bin/java /usr/lib/jvm/java-6-sun/jre/bin/java |
update-alternatives --config
blueice:~# update-alternatives --config java There are 4 alternatives which provide `java'. Selection Alternative ----------------------------------------------- 1 /usr/bin/gij-wrapper-4.0 2 /usr/bin/gij-wrapper-4.1 + 3 /usr/lib/jvm/java-gcj/jre/bin/java * 4 /usr/lib/jvm/java-6-sun/jre/bin/java Press enter to keep the default[*], or type selection number: 4 Using `/usr/lib/jvm/java-6-sun/jre/bin/java' to provide `java'. |
其中, '+'表示推荐的候选命令, '*'表示实际指向的候选命令.
update-alternatives --all则可以配置系统上所有的候选命令.
事实上, update-alternatives通过修改/etc/alternatives下的链接来实现候选命令的更改.
blueice:~# ls -al /usr/bin/java lrwxrwxrwx 1 root root 22 Aug 30 2005 /usr/bin/java -> /etc/alternatives/java blueice:~# ls -al /etc/alternatives/java lrwxrwxrwx 1 root root 36 Jul 24 22:21 /etc/alternatives/java -> /usr/lib/jvm/java-6-sun/jre/bin/java blueice:~# s -al /usr/lib/jvm/java-6-sun/jre/bin/java -rwxr-xr-x 1 root root 47116 Jun 15 07:26 /usr/lib/jvm/java-6-sun/jre/bin/java |