Summary of learning alternatives command under Linux

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:

  1. Basic syntax of the alternatives command:

    alternatives --config <link>
    alternatives --display <link>
    alternatives --install <link> <name> <path> <priority>
    alternatives --remove <name> <path>
  2. Use  --configoptions 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
  3. Use  --displaythe 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
  4. Use  --installoption 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
  5. Use  --removeoption 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.

Guess you like

Origin blog.csdn.net/tiansyun/article/details/132267998