This is an article for describing on how to list available specific command. That command exists in Debian or Ubuntu based operating system and it also may exists in other Linux-based distribution. That specific command is the ‘update-alternatives’. Since in this article the example given is using the Ubuntu based operating system, the command used in this article is an Ubuntu-linux based compatible. If the operating system used is different, perform the suitable command suitable in the operating system used.
So, what is the actual function of the ‘update-alternatives command ?. The information showing about the ‘update-alternatives’ command exists in the manual page. Type the following command to show the manual page containing the information about the ‘update-alternatives’ command :
man update-alternatives
The output of the above command is shown as follows :
update-alternatives(1) dpkg suite update-alternatives(1) NAME update-alternatives - maintain symbolic links determining default commands ...
Based on part of the output above, it informs that the ‘update-alternatives’ is a command for maintaining symbolic links determining default commands. Every kinds of command exist and available in the operating system is suitable for further maintaining. Basically, the maintaining process is defining the default symbolic links selected for executing the command.
But in the context of this article, the command ‘update-alternatives”s usage is basically about how to list or to display the available symbolic links defined for the specific command. To be able to do that, just add another parameter after the ‘update-alternatives’ command. That parameter is ‘-display’ followed with the name of the specific command. Based on the information from the manual page of ‘update-alternatives’, the parameter ‘-display’ has the function as follows :
--display name Display information about the link group. Information displayed includes the group's mode (auto or manual), the master and slave links, which alternative the master link currently points to, what other alternatives are available (and their corresponding slave alternatives), and the highest priority alternative currently installed.
So, following the order of the command pattern for showing the symbolic link for ‘java’ command explained above, the command is :
update-alternatives --display java </pre
Below is the output of the above command execution which contains an error message. It is because there is no definition of ‘java’ command available.
user@hostname:~$ update-alternatives --display java update-alternatives: error: no alternatives for java user@hostname:~$
The following is a different output if there is a symbolic link definition available for ‘java’ command :
user@hostname:~$ update-alternatives --display java java - auto mode link best version is /opt/jdk1.8.0_181/bin/java link currently points to /opt/jdk1.8.0_181/bin/java link java is /usr/bin/java /opt/jdk1.8.0_181/bin/java - priority 1 user@hostname:~$
If there are more than one symbolic link definition available, the following is the output of the command execution :
user@hostname:~$ update-alternatives --display java java - auto mode link best version is /usr/lib/jvm/java-11-openjdk-amd64/bin/java link currently points to /usr/lib/jvm/java-11-openjdk-amd64/bin/java link java is /usr/bin/java /opt/jdk1.8.0_181/bin/java - priority 1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java - priority 2 user@hostname:~$
One thought on “How to List Available Symbolic Link of a Specific Command using update-alternatives”