linux: lang: alternatives

 

alternatives


Link: https://serverfault.com/questions/838592/how-to-remove-update-alternatives-links-on-linux

  • Links stored in
/var/lib/alternatives

 

--install

alternatives --install <link> <name> <path> <priority>

 

  • <link> = fake path
  • <name> = identifier for keeping the alternative links
  • <path> = REAL path
  • <priority> = int representing

 

--help

alternatives version 1.7.4 - Copyright (C) 2001 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.

usage: alternatives --install <link> <name> <path> <priority>
                    [--initscript <service>]
                    [--family <family>]
                    [--slave <link> <name> <path>]*
       alternatives --remove <name> <path>
       alternatives --auto <name>
       alternatives --config <name>
       alternatives --display <name>
       alternatives --set <name> <path>
       alternatives --list

common options: --verbose --test --help --usage --version --keep-missing
                --altdir <directory> --admindir <directory>
                

 

alternatives --install /usr/bin/java java /opt/jdk1.8.0_171/bin/java 1
failed to read link /usr/bin/java: No such file or directory
failed to create /var/lib/alternatives/java.new: Permission denied
[psqa@centos7dev alternatives]$ sudo alternatives --install /usr/bin/java java /opt/jdk1.8.0_171/bin/java 1
failed to read link /usr/bin/java: No such file or directory

 

cat /var/lib/alternatives/java
auto
/usr/bin/java

/opt/jdk1.8.0_171/bin/java
1


--config <name>

sudo alternatives --config java

There is 1 program that provides 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /opt/jdk1.8.0_171/bin/java

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

 

Tags