How does `update-alternatives --config somecommand` find the symlinks for `somecommand`?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
From https://stackoverflow.com/a/48374564/156458
update-alternatives --config java
works by installing symlinks to commands as/usr/bin/java
,/usr/bin/javac
and so on.
How does update-alternatives --config somecommand
find the symlinks for somecommand
?
For example, does it rely on $PATH
, and therefore work in the same way as how bash find the files for somecommand
when running somecommand
directly in bash?
If the file for somecommand
is not a symlink, will update-alternative --config somecommand
work?
Thanks.
software-installation path alternatives
add a comment |Â
up vote
1
down vote
favorite
From https://stackoverflow.com/a/48374564/156458
update-alternatives --config java
works by installing symlinks to commands as/usr/bin/java
,/usr/bin/javac
and so on.
How does update-alternatives --config somecommand
find the symlinks for somecommand
?
For example, does it rely on $PATH
, and therefore work in the same way as how bash find the files for somecommand
when running somecommand
directly in bash?
If the file for somecommand
is not a symlink, will update-alternative --config somecommand
work?
Thanks.
software-installation path alternatives
1
I usually (ab)useltrace
andstrace
for those quick doubts.
â Rui F Ribeiro
Jan 22 at 13:28
Or, list the contents of the package that provides the command/binary, and traverse the directories and read its manpage(s).
â ILMostro_7
Jan 22 at 13:42
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
From https://stackoverflow.com/a/48374564/156458
update-alternatives --config java
works by installing symlinks to commands as/usr/bin/java
,/usr/bin/javac
and so on.
How does update-alternatives --config somecommand
find the symlinks for somecommand
?
For example, does it rely on $PATH
, and therefore work in the same way as how bash find the files for somecommand
when running somecommand
directly in bash?
If the file for somecommand
is not a symlink, will update-alternative --config somecommand
work?
Thanks.
software-installation path alternatives
From https://stackoverflow.com/a/48374564/156458
update-alternatives --config java
works by installing symlinks to commands as/usr/bin/java
,/usr/bin/javac
and so on.
How does update-alternatives --config somecommand
find the symlinks for somecommand
?
For example, does it rely on $PATH
, and therefore work in the same way as how bash find the files for somecommand
when running somecommand
directly in bash?
If the file for somecommand
is not a symlink, will update-alternative --config somecommand
work?
Thanks.
software-installation path alternatives
asked Jan 22 at 13:09
Tim
22.7k65224403
22.7k65224403
1
I usually (ab)useltrace
andstrace
for those quick doubts.
â Rui F Ribeiro
Jan 22 at 13:28
Or, list the contents of the package that provides the command/binary, and traverse the directories and read its manpage(s).
â ILMostro_7
Jan 22 at 13:42
add a comment |Â
1
I usually (ab)useltrace
andstrace
for those quick doubts.
â Rui F Ribeiro
Jan 22 at 13:28
Or, list the contents of the package that provides the command/binary, and traverse the directories and read its manpage(s).
â ILMostro_7
Jan 22 at 13:42
1
1
I usually (ab)use
ltrace
and strace
for those quick doubts.â Rui F Ribeiro
Jan 22 at 13:28
I usually (ab)use
ltrace
and strace
for those quick doubts.â Rui F Ribeiro
Jan 22 at 13:28
Or, list the contents of the package that provides the command/binary, and traverse the directories and read its manpage(s).
â ILMostro_7
Jan 22 at 13:42
Or, list the contents of the package that provides the command/binary, and traverse the directories and read its manpage(s).
â ILMostro_7
Jan 22 at 13:42
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
The way update-alternatives
works is described in its manpage. The list of available alternatives for a given command (or file, in general â alternatives arenâÂÂt limited to commands) is stored in a file in /var/lib/dpkg/alternatives
on Debian and derivatives; thus the alternatives for java
are stored in /var/lib/dpkg/alternatives/java
. On Fedora, RHEL, and derivatives, the files are stored in /var/lib/alternatives
.
When a package wishes to provide an alternative, it installs it using update-alternatives --install
(and appropriate parameters); when it wishes to remove an alternative, it does so using update-alternatives --remove
. You can use these to provide your own alternatives if necessary.
Note that in JavaâÂÂs case specifically, on Debian and derivatives, the alternatives handling is a little more complex and you should use update-java-alternatives
instead of manipulating all the alternatives manually.
If for some reason an alternative-managed file is not a symlink, update-alternatives
will consider that the alternative is broken and will refuse to touch it.
Interesting note about java alternatives there. I'm not at all familiar with how or why that would be the case, however usingupdate-alternatives
has always worked for me when dealing with java. Additionally, while the original work was created by debian developers, RedHat-based distros have adapted it as well. Although, there is no specificupdate-java-alternatives
command on RHEL, e.g. It might be worth noting as well, on RedHat-based systems, the path is/var/lib/alternatives
for the alternative scripts.
â ILMostro_7
Jan 22 at 13:48
1
@ILMostro_7 right,update-alternatives
still works,update-java-alternatives
makes it easier to update all the JRE/JDK-provided tools when changing JVMs (look at the/var/lib/jvm/.*.jinfo
files for details). Thanks for the comment, IâÂÂve updated my answer.
â Stephen Kitt
Jan 22 at 13:51
Thanks. Why "in JavaâÂÂs case specifically, on Debian and derivatives, the alternatives handling is a little more complex and you should use update-java-alternatives instead of manipulating all the alternatives manually" ? I am reading askubuntu.com/questions/159575/â¦, but still can't figure it out.
â Tim
Jan 22 at 15:28
@Tim, for Java packages, there are lots of different alternatives, none of which are connected (partly because you might only have a sub-selection of the commands installed); so if you want to switch from Java 8 to Java 9 for example, youâÂÂd have to update a couple of dozen alternatives manually...update-java-alternatives
does that for you.
â Stephen Kitt
Jan 22 at 15:30
What are " a couple of dozen alternatives" that I have to update manually? Is$JAVA_HOME
included?
â Tim
Jan 22 at 15:39
 |Â
show 7 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
The way update-alternatives
works is described in its manpage. The list of available alternatives for a given command (or file, in general â alternatives arenâÂÂt limited to commands) is stored in a file in /var/lib/dpkg/alternatives
on Debian and derivatives; thus the alternatives for java
are stored in /var/lib/dpkg/alternatives/java
. On Fedora, RHEL, and derivatives, the files are stored in /var/lib/alternatives
.
When a package wishes to provide an alternative, it installs it using update-alternatives --install
(and appropriate parameters); when it wishes to remove an alternative, it does so using update-alternatives --remove
. You can use these to provide your own alternatives if necessary.
Note that in JavaâÂÂs case specifically, on Debian and derivatives, the alternatives handling is a little more complex and you should use update-java-alternatives
instead of manipulating all the alternatives manually.
If for some reason an alternative-managed file is not a symlink, update-alternatives
will consider that the alternative is broken and will refuse to touch it.
Interesting note about java alternatives there. I'm not at all familiar with how or why that would be the case, however usingupdate-alternatives
has always worked for me when dealing with java. Additionally, while the original work was created by debian developers, RedHat-based distros have adapted it as well. Although, there is no specificupdate-java-alternatives
command on RHEL, e.g. It might be worth noting as well, on RedHat-based systems, the path is/var/lib/alternatives
for the alternative scripts.
â ILMostro_7
Jan 22 at 13:48
1
@ILMostro_7 right,update-alternatives
still works,update-java-alternatives
makes it easier to update all the JRE/JDK-provided tools when changing JVMs (look at the/var/lib/jvm/.*.jinfo
files for details). Thanks for the comment, IâÂÂve updated my answer.
â Stephen Kitt
Jan 22 at 13:51
Thanks. Why "in JavaâÂÂs case specifically, on Debian and derivatives, the alternatives handling is a little more complex and you should use update-java-alternatives instead of manipulating all the alternatives manually" ? I am reading askubuntu.com/questions/159575/â¦, but still can't figure it out.
â Tim
Jan 22 at 15:28
@Tim, for Java packages, there are lots of different alternatives, none of which are connected (partly because you might only have a sub-selection of the commands installed); so if you want to switch from Java 8 to Java 9 for example, youâÂÂd have to update a couple of dozen alternatives manually...update-java-alternatives
does that for you.
â Stephen Kitt
Jan 22 at 15:30
What are " a couple of dozen alternatives" that I have to update manually? Is$JAVA_HOME
included?
â Tim
Jan 22 at 15:39
 |Â
show 7 more comments
up vote
4
down vote
accepted
The way update-alternatives
works is described in its manpage. The list of available alternatives for a given command (or file, in general â alternatives arenâÂÂt limited to commands) is stored in a file in /var/lib/dpkg/alternatives
on Debian and derivatives; thus the alternatives for java
are stored in /var/lib/dpkg/alternatives/java
. On Fedora, RHEL, and derivatives, the files are stored in /var/lib/alternatives
.
When a package wishes to provide an alternative, it installs it using update-alternatives --install
(and appropriate parameters); when it wishes to remove an alternative, it does so using update-alternatives --remove
. You can use these to provide your own alternatives if necessary.
Note that in JavaâÂÂs case specifically, on Debian and derivatives, the alternatives handling is a little more complex and you should use update-java-alternatives
instead of manipulating all the alternatives manually.
If for some reason an alternative-managed file is not a symlink, update-alternatives
will consider that the alternative is broken and will refuse to touch it.
Interesting note about java alternatives there. I'm not at all familiar with how or why that would be the case, however usingupdate-alternatives
has always worked for me when dealing with java. Additionally, while the original work was created by debian developers, RedHat-based distros have adapted it as well. Although, there is no specificupdate-java-alternatives
command on RHEL, e.g. It might be worth noting as well, on RedHat-based systems, the path is/var/lib/alternatives
for the alternative scripts.
â ILMostro_7
Jan 22 at 13:48
1
@ILMostro_7 right,update-alternatives
still works,update-java-alternatives
makes it easier to update all the JRE/JDK-provided tools when changing JVMs (look at the/var/lib/jvm/.*.jinfo
files for details). Thanks for the comment, IâÂÂve updated my answer.
â Stephen Kitt
Jan 22 at 13:51
Thanks. Why "in JavaâÂÂs case specifically, on Debian and derivatives, the alternatives handling is a little more complex and you should use update-java-alternatives instead of manipulating all the alternatives manually" ? I am reading askubuntu.com/questions/159575/â¦, but still can't figure it out.
â Tim
Jan 22 at 15:28
@Tim, for Java packages, there are lots of different alternatives, none of which are connected (partly because you might only have a sub-selection of the commands installed); so if you want to switch from Java 8 to Java 9 for example, youâÂÂd have to update a couple of dozen alternatives manually...update-java-alternatives
does that for you.
â Stephen Kitt
Jan 22 at 15:30
What are " a couple of dozen alternatives" that I have to update manually? Is$JAVA_HOME
included?
â Tim
Jan 22 at 15:39
 |Â
show 7 more comments
up vote
4
down vote
accepted
up vote
4
down vote
accepted
The way update-alternatives
works is described in its manpage. The list of available alternatives for a given command (or file, in general â alternatives arenâÂÂt limited to commands) is stored in a file in /var/lib/dpkg/alternatives
on Debian and derivatives; thus the alternatives for java
are stored in /var/lib/dpkg/alternatives/java
. On Fedora, RHEL, and derivatives, the files are stored in /var/lib/alternatives
.
When a package wishes to provide an alternative, it installs it using update-alternatives --install
(and appropriate parameters); when it wishes to remove an alternative, it does so using update-alternatives --remove
. You can use these to provide your own alternatives if necessary.
Note that in JavaâÂÂs case specifically, on Debian and derivatives, the alternatives handling is a little more complex and you should use update-java-alternatives
instead of manipulating all the alternatives manually.
If for some reason an alternative-managed file is not a symlink, update-alternatives
will consider that the alternative is broken and will refuse to touch it.
The way update-alternatives
works is described in its manpage. The list of available alternatives for a given command (or file, in general â alternatives arenâÂÂt limited to commands) is stored in a file in /var/lib/dpkg/alternatives
on Debian and derivatives; thus the alternatives for java
are stored in /var/lib/dpkg/alternatives/java
. On Fedora, RHEL, and derivatives, the files are stored in /var/lib/alternatives
.
When a package wishes to provide an alternative, it installs it using update-alternatives --install
(and appropriate parameters); when it wishes to remove an alternative, it does so using update-alternatives --remove
. You can use these to provide your own alternatives if necessary.
Note that in JavaâÂÂs case specifically, on Debian and derivatives, the alternatives handling is a little more complex and you should use update-java-alternatives
instead of manipulating all the alternatives manually.
If for some reason an alternative-managed file is not a symlink, update-alternatives
will consider that the alternative is broken and will refuse to touch it.
edited Jan 22 at 13:53
answered Jan 22 at 13:15
Stephen Kitt
142k22308371
142k22308371
Interesting note about java alternatives there. I'm not at all familiar with how or why that would be the case, however usingupdate-alternatives
has always worked for me when dealing with java. Additionally, while the original work was created by debian developers, RedHat-based distros have adapted it as well. Although, there is no specificupdate-java-alternatives
command on RHEL, e.g. It might be worth noting as well, on RedHat-based systems, the path is/var/lib/alternatives
for the alternative scripts.
â ILMostro_7
Jan 22 at 13:48
1
@ILMostro_7 right,update-alternatives
still works,update-java-alternatives
makes it easier to update all the JRE/JDK-provided tools when changing JVMs (look at the/var/lib/jvm/.*.jinfo
files for details). Thanks for the comment, IâÂÂve updated my answer.
â Stephen Kitt
Jan 22 at 13:51
Thanks. Why "in JavaâÂÂs case specifically, on Debian and derivatives, the alternatives handling is a little more complex and you should use update-java-alternatives instead of manipulating all the alternatives manually" ? I am reading askubuntu.com/questions/159575/â¦, but still can't figure it out.
â Tim
Jan 22 at 15:28
@Tim, for Java packages, there are lots of different alternatives, none of which are connected (partly because you might only have a sub-selection of the commands installed); so if you want to switch from Java 8 to Java 9 for example, youâÂÂd have to update a couple of dozen alternatives manually...update-java-alternatives
does that for you.
â Stephen Kitt
Jan 22 at 15:30
What are " a couple of dozen alternatives" that I have to update manually? Is$JAVA_HOME
included?
â Tim
Jan 22 at 15:39
 |Â
show 7 more comments
Interesting note about java alternatives there. I'm not at all familiar with how or why that would be the case, however usingupdate-alternatives
has always worked for me when dealing with java. Additionally, while the original work was created by debian developers, RedHat-based distros have adapted it as well. Although, there is no specificupdate-java-alternatives
command on RHEL, e.g. It might be worth noting as well, on RedHat-based systems, the path is/var/lib/alternatives
for the alternative scripts.
â ILMostro_7
Jan 22 at 13:48
1
@ILMostro_7 right,update-alternatives
still works,update-java-alternatives
makes it easier to update all the JRE/JDK-provided tools when changing JVMs (look at the/var/lib/jvm/.*.jinfo
files for details). Thanks for the comment, IâÂÂve updated my answer.
â Stephen Kitt
Jan 22 at 13:51
Thanks. Why "in JavaâÂÂs case specifically, on Debian and derivatives, the alternatives handling is a little more complex and you should use update-java-alternatives instead of manipulating all the alternatives manually" ? I am reading askubuntu.com/questions/159575/â¦, but still can't figure it out.
â Tim
Jan 22 at 15:28
@Tim, for Java packages, there are lots of different alternatives, none of which are connected (partly because you might only have a sub-selection of the commands installed); so if you want to switch from Java 8 to Java 9 for example, youâÂÂd have to update a couple of dozen alternatives manually...update-java-alternatives
does that for you.
â Stephen Kitt
Jan 22 at 15:30
What are " a couple of dozen alternatives" that I have to update manually? Is$JAVA_HOME
included?
â Tim
Jan 22 at 15:39
Interesting note about java alternatives there. I'm not at all familiar with how or why that would be the case, however using
update-alternatives
has always worked for me when dealing with java. Additionally, while the original work was created by debian developers, RedHat-based distros have adapted it as well. Although, there is no specific update-java-alternatives
command on RHEL, e.g. It might be worth noting as well, on RedHat-based systems, the path is /var/lib/alternatives
for the alternative scripts.â ILMostro_7
Jan 22 at 13:48
Interesting note about java alternatives there. I'm not at all familiar with how or why that would be the case, however using
update-alternatives
has always worked for me when dealing with java. Additionally, while the original work was created by debian developers, RedHat-based distros have adapted it as well. Although, there is no specific update-java-alternatives
command on RHEL, e.g. It might be worth noting as well, on RedHat-based systems, the path is /var/lib/alternatives
for the alternative scripts.â ILMostro_7
Jan 22 at 13:48
1
1
@ILMostro_7 right,
update-alternatives
still works, update-java-alternatives
makes it easier to update all the JRE/JDK-provided tools when changing JVMs (look at the /var/lib/jvm/.*.jinfo
files for details). Thanks for the comment, IâÂÂve updated my answer.â Stephen Kitt
Jan 22 at 13:51
@ILMostro_7 right,
update-alternatives
still works, update-java-alternatives
makes it easier to update all the JRE/JDK-provided tools when changing JVMs (look at the /var/lib/jvm/.*.jinfo
files for details). Thanks for the comment, IâÂÂve updated my answer.â Stephen Kitt
Jan 22 at 13:51
Thanks. Why "in JavaâÂÂs case specifically, on Debian and derivatives, the alternatives handling is a little more complex and you should use update-java-alternatives instead of manipulating all the alternatives manually" ? I am reading askubuntu.com/questions/159575/â¦, but still can't figure it out.
â Tim
Jan 22 at 15:28
Thanks. Why "in JavaâÂÂs case specifically, on Debian and derivatives, the alternatives handling is a little more complex and you should use update-java-alternatives instead of manipulating all the alternatives manually" ? I am reading askubuntu.com/questions/159575/â¦, but still can't figure it out.
â Tim
Jan 22 at 15:28
@Tim, for Java packages, there are lots of different alternatives, none of which are connected (partly because you might only have a sub-selection of the commands installed); so if you want to switch from Java 8 to Java 9 for example, youâÂÂd have to update a couple of dozen alternatives manually...
update-java-alternatives
does that for you.â Stephen Kitt
Jan 22 at 15:30
@Tim, for Java packages, there are lots of different alternatives, none of which are connected (partly because you might only have a sub-selection of the commands installed); so if you want to switch from Java 8 to Java 9 for example, youâÂÂd have to update a couple of dozen alternatives manually...
update-java-alternatives
does that for you.â Stephen Kitt
Jan 22 at 15:30
What are " a couple of dozen alternatives" that I have to update manually? Is
$JAVA_HOME
included?â Tim
Jan 22 at 15:39
What are " a couple of dozen alternatives" that I have to update manually? Is
$JAVA_HOME
included?â Tim
Jan 22 at 15:39
 |Â
show 7 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f418852%2fhow-does-update-alternatives-config-somecommand-find-the-symlinks-for-somec%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
I usually (ab)use
ltrace
andstrace
for those quick doubts.â Rui F Ribeiro
Jan 22 at 13:28
Or, list the contents of the package that provides the command/binary, and traverse the directories and read its manpage(s).
â ILMostro_7
Jan 22 at 13:42