If you have installed Linux OS from our templates, 2 editors are already available for you to use: nano and vi/vim. This article will focus on the nano editor - a very simple editor that is accessible to a user of any level.
If for some reason the nano editor is not installed, then it can be installed by running the install command. For rpm-based distributions:
yum install nano
For deb-based, the command is:
apt-get install nano
To work with the program, you need to log into the server using the SSH protocol. For example, on Windows, by installing the PuTTY program, and on Linux or Mac, use the built-in ssh program. Depending on the Linux system and the program you are using to connect to the server, copy and paste from your operating system's clipboard can be used. For example, you can paste text into PuTTY using the SHIFT+INS combination, and copy it by simply selecting the text. Unfortunately, this does not work on all Linux distributions on the server.
In order to start the editor, log in to the server via SSH using any available client - built into your OS or, for example, PuTTYand run the command:
nano
To edit a specific file, specify the path to the file - full or relative:
nano /path/to/file
Consider the appearance of the main editor window.
Image 1. Appearance of the nano editor
At the top of the window you can see the name and version of the program, the name of the file being edited and the path to it, the '*' (asterisk) icon, which indicates that changes have been made that have not been saved, as well as other service information. Next comes a large area with the contents of a text file. This is where the file is viewed and edited. At the bottom is a quick access bar that lists keyboard shortcuts for the most common commands.
You can move through the text with the arrows, as well as with the HOME, END, PG UP, PG DOWN buttons.
Here are some useful combinations and commands while working with the nano editor. In older versions of the program, the combinations may differ.
CTRL+X - exit the editor. If changes were made that you did not save, you will be asked to save to a file.
CTRL+O - save file
CTRL+W - search by file
ALT+S - enable/disable word wrap (the letter S appears at the top right)
ALT+U - cancel action
ALT+E - repeat action
Separately, I want to note text editing possibilities. You can select, cut, copy, paste. To select text, use the ALT+A combination. The character under the cursor is not included in the selection. When the desired fragment is selected, press ALT+6 to copy or CTRL+K to cut, navigate to a new location and press CTRL+U to paste.
For example, let's select the text (ALT+A).
Image 2. Text selection
Copy (ALT+6) and paste (CTRL+U) it several times (move cursor to desired location):
Image 2. Inserting text