Text Editor

Choosing a text editor in the Linux console

Linux virtual servers are not equipped with any kind of graphical interface, so they are administered through the console – either through the web console embedded in the Xelent control panel or via SSH. Often, the administrator has a need to edit some server configuration file.

As a rule, there are no problems with this – launch the preferred text editor, open the file, edit and save. However, some configuration files, in particular, / etc / sudoers, are edited only through special utilities (in this case, visudo or crontab, when editing the scheduler’s schedule), which launch the text editor for the default Linux console.

This is vi, which has migrated to modern Linux distributions since the  1970s and cannot be called convenient. In this note, some text editors will be considered, and it will be shown how to set what you like by default so that it will be called up when editing some special configuration files that cannot be edited manually.

Variety of choices

The most convenient and simple, known to me, text editor Linux console is nano (it used to be called pico and was part of the pine client). Nano is depicted in Fig. one.

Variety Of Choices

Fig. 1. Nano

Below (under the text) there is a hint on the key combinations for managing the editor. The ^ symbol means <Ctrl>. That is, to exit ytuj, press the key combination <Ctrl> + <X>, and to save the text – <Ctrl> + <O>.

On some systems (for example, FreeBSD), instead of nano, ee is used (not in Linux). It is similar to nano, but there are differences – hints are displayed before the text (at the top of the screen), and not after it, but the idea is the same. Also quite convenient is joe. Let’s just say, the text editor Linux nano console will be more convenient, it supports syntax highlighting, at the bottom, there is a panel with hints, but this is a matter of habit.

Xelent

Fig. 2. joe 

The mc package (file manager) includes a good and quite convenient mcedit, which starts when you press the <F4> key in mc (Fig. 3). But you can run console text editors in Linux separately:

mcedit <file name>

Mcedit

Fig. 3. mcedit

Classic blue background, tips of the function keys below, etc. Not less convenient than the nano. Linux console text editors joe, nano, and ee run in the same way:

joe <file name>

nano <file name>

ee <file name>

We just looked at three text editors for Linux (one was for FreeBSD). The choice of a particular one depends on your personal preferences. But in any case, each of the options presented will be more convenient than standard vi.

Making the selected text editor the default

To do this, it is enough to set the environment variable EDITOR:

which nano

/ bin / nano

export EDITOR = / bin / nano

The first command (which nano) tells the path to the selected editor. Next, we need to specify this path as the value of the EDITOR variable.

Just remember that the next time you log in, the EDITOR variable will be set by default. To avoid this, you need to edit the .bashrc file of the user on whose behalf you will edit the configuration files. In the case of root, this will be the file /root/.bashrc:

cd ~ 

nano.bashrc

In this file (Fig. 4) you need to add the command:

export EDITOR = / bin / nano

Save the file. Now you need to log out (exit command) and log in again (via SSH or via the Web console ). After that, run any command that calls the standard text editor, for example, crontab -e. If you saw your chosen option, then everything went fine. Otherwise, you made a mistake somewhere.

Ssh

Fig. 4. Editing .bashrc

When Editing The Schedule (Crontab -E Command), Nano Opened

Fig. 5. When editing the schedule (crontab -e command), nano opened. Setup successful 

In this article, we looked at choosing a text editor and setting it as the default editor. If you have any questions, contact Xelent technical support.

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply

    Your email address will not be published. Required fields are marked *