The alternatives command is a tool in the Linux system for managing various alternative commands in the system. It helps you set default commands in your system and find available alternatives. The following is a summary of learning about the alternatives command:
-
Basic syntax of the alternatives command:
alternatives --config <link> alternatives --display <link> alternatives --install <link> <name> <path> <priority> alternatives --remove <name> <path>
-
Use
--config
options to list and select available alternative commands. For example, the following command can be used to select the default editor on the system:alternatives --config editor
-
Use
--display
the option to display details of installed alternative commands. For example, the following command can be used to display the alternative command information for Java on the system:alternatives --display java
-
Use
--install
option to install a new replacement command. It requires specifying the name, path, and priority of an alternate command. For example, an alternative to Java can be installed into the system with the following command:alternatives --install /usr/bin/java java /usr/local/java/bin/java 1
-
Use
--remove
option to remove an installed replacement command from the system. For example, an alternative to removing Java from your system can be done with the following command:alternatives --remove java /usr/local/java/bin/java
It should be noted that using the alternatives command requires administrator privileges. Before using a command, make sure you understand the path and priority of the replacement command you want to install or remove, and do so carefully to avoid accidental changes.
With the alternatives command, you can easily manage alternative commands in the system and set default command options. This is useful in situations where there are multiple similar commands in the system, such as different versions of compilers or interpreters. Hope these summaries help you understand and use the alternatives command.