update-alternatives Command: Tutorial & Examples
Configure default programs for your system
The update-alternatives command is a utility in Linux that allows you to set default programs for various tasks on your system. One of the tasks that update-alternatives can manage is the default text editor, which is the program that is used when you open a text file from the command line or when you edit a file using a command like nano.
To set the default text editor on your Linux system using update-alternatives, you will need to follow these steps:
Install the text editor that you want to set as the default. If you have not already done so, you will need to install the text editor on your system using your package manager or by compiling the source code.
Update the update-alternatives database. Run the following command to update the update-alternatives database with information about the text editor that you installed:
$ sudo update-alternatives --install /usr/bin/editor editor /path/to/text/editor 50
Replace /path/to/text/editor with the path to the executable file for the text editor that you installed. The 50 at the end of the command is the priority of the text editor, which determines the order in which it will be selected if there are multiple alternatives available.
Set the default text editor. Run the following command to set the text editor that you installed as the default:
$ sudo update-alternatives --config editor
This command will display a list of available text editors, and you can select the one that you want to use as the default by entering its number.
After you have completed these steps, the text editor that you selected will be set as the default editor on your system. If you want to change the default editor at a later time, you can use the update-alternatives --config editor command again to select a different editor.