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.
ltrace
andstrace
for those quick doubts. – Rui F Ribeiro Jan 22 '18 at 13:28