How to Install and Use Nano Text Editor
Nano will enable you to edit text files in your VPS on the command line when you are logged in using SSH.
Step1:Installing Nano Text Editor CentOS
yum install nano
you can test it out by writing this command
nano testfile.txt
It should open a new text editor window and if you make any changes to this file, they will be saved under the name test.txt.
To exit Nano, for now, press CTRL + X. It will you ask whether to save changes in the file. Enter y for yes and then press ENTER.
Step2:Using Nano Text Editor
Command | Explanation |
CTRL + A | Jump to the beginning of the line. |
CTRL + E | Jump to the end of the line. |
CTRL + Y | Scroll page down. |
CTRL + V | Scroll page up. |
CTRL + G | This command will bring up a Help window which has information regarding all the commands you can use with the Nano editor. |
CTRL + O | Basically a save command. When used, you will be prompted to edit or verify the desired file name and after pressing enter, it will save your file. |
CTRL + W | One of the most useful commands. It’s used to search for a specified phrase in your text. It works much like the usual CTRL+F command on other apps and platforms. To search for the same phrase again press ALT + W. |
CTRL + K | Cuts the entire selected line to the “cut buffer”. |
CTRL + U | Pastes the text from the “cut buffer” into the selected line. |
CTRL + J | Justifies the current paragraph. |
CTRL + C | Shows the current cursor position in the text (line/column/character). |
CTRL + X | Exits Nano text editor. In case you made any changes to the file, it will additionally prompt a save request. |
CTRL + R | Open a file with “Read File” command. Inserts file from disk at the current cursor position. |
CTRL + \ | Replace string or a regular expression. |
CTRL + T | Invoke the spell checker, if available. |
CTRL + _ | Go to specified line and column number |
ALT + A | Select text. First, move the cursor to the beginning of a specific part of the text which you want to select, then press ALT + A. Now move the cursor with arrow keys to the right, this will start marking/selecting text. You can combine this command with CTRL + K to cut a specific part of the text to the “cut buffer”. |