Monday, May 6, 2024
106
rated 0 times [  106] [ 0]  / answers: 1 / hits: 127931  / 1 Year ago, fri, march 31, 2023, 3:22:46

What is the command update-alternatives used for?



Take this example:



sudo update-alternatives --install /usr/bin/java java /usr/local/java/jre1.7.0_09/bin/java 1


What does it do? How is it different from adding jdk to the path?



Let's say that I have run the command. How would I revert back to the original state?


More From » update-alternatives

 Answers
2

It updates the links in /etc/alternatives to point to the program for this purpose. There's lots of examples, like x-www-browser, editor, etc. that will link to the browser or editor of your preference. Some scripts or system tools may want you to edit a file manually (e.g. configuration conflict in dpkg) and they'll look into the alternatives to give you the editor of choice. For java, this is the Java runtime environment - Oracle's, OpenJRE, etc.



The links in /etc/alternatives are just symbolic links. You can see them using for example



ls -l /etc/alternatives


Moreover, the regular /usr/bin binaries are also symlinks. E.g.:



ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Aug 14 10:33 /usr/bin/java -> /etc/alternatives/java
ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 46 Aug 14 10:33 /etc/alternatives/java -> /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java


So, no PATH has to be modified. It just uses symbolic links.


[#33497] Friday, March 31, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hergy

Total Points: 64
Total Questions: 115
Total Answers: 109

Location: Saint Helena
Member since Tue, Nov 3, 2020
4 Years ago
hergy questions
Tue, Aug 31, 21, 08:36, 3 Years ago
Thu, Mar 31, 22, 11:18, 2 Years ago
;