Using update-alternatives to switch between software
Linux makes it super easy to switch between different binaries (aka versions) of software you have installed using symlinks. To help manage this process there is tool that comes on most big distributions called update-alternatives. Here the output of the following command:
[allinnia@fedora ~]$ sudo update-alternatives --help
alternatives version 1.24 - 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>]
[--follower <follower_link> <follower_name> <follower_path>]*
alternatives --remove <name> <path>
alternatives --auto <name>
alternatives --config <name>
alternatives --display <name>
alternatives --set <name> <path/family>
alternatives --list
alternatives --remove-all <name>
alternatives --add-follower <name> <path> <follower_link> <follower_name> <follower_path>
alternatives --remove-follower <name> <path> <follower_name>
common options: --verbose --test --help --usage --version --keep-missing --keep-foreign
--altdir <directory> --admindir <directory>
The particular one we are interested in is the –config option. With this you can enter the command you would like to switch version on. For this example, I will enter java since it is installed on my system.
[allinnia@fedora ~]$ sudo update-alternatives --config java
There is 1 program that provides 'java'.
Selection Command
-----------------------------------------------
*+ 1 java-17-openjdk.x86_64 (/usr/lib/jvm/java-17-openjdk-17.0.7.0.7-5.fc38.x86_64/bin/java)
Enter to keep the current selection[+], or type selection number:
Unfortunately, I don’t have any other versions / packages of java installed. If I did, I could easily select it by typing in the number to the left and the program will automatically create the relevant symlinks for you! This is particularly useful if you do need to operate in multiple versions (usually older) of certain software. Switching over really quick to make an edit is a breeze. If you run the command:
java -version
You should see the version you selected now accurately reflected! I hope this helps you somewhere down the line!