Monday, May 21, 2012

Alternatives usage


Alternatives allows you to toggle between several version of the installed binary using symlink. Alternatives has a default administrative directory as /var/lib/alternatives where it keeps all the metadata


Most common usage of alternatives are
alternatives --install
alternatives --config
alternatives --remove

usage: alternatives --install
update-alternatives --install "/usr/bin/java" "java" "/usr/java/default/bin/java" 3

lrwxrwxrwx. 1 root root 12 Feb 22 20:04 /usr/sbin/update-alternatives -> alternatives

ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 35 Jun  8  2010 /etc/alternatives/java -> /usr/lib/jvm/jre-1.4.2-gcj/bin/java


[root@pg ~]# alternatives --config java

There is 1 program that provides 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java


update-alternatives --install /usr/bin/java java /usr/bin/jade 3

[root@pg ~]# alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
   2           /usr/bin/jade

Enter to keep the current selection[+], or type selection number:



[root@pg ~]# alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*  1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
 + 2           /usr/bin/jade

Enter to keep the current selection[+], or type selection number:


[root@pg ~]# ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 13 Apr 24 01:33 /etc/alternatives/java -> /usr/bin/jade



No comments: