How to use Nano

When editing files there are two main types of text editors in use, Nano and Vim. Although Nano is not installed by default on most Linux flavours, it does seem to be a favourite due to its better use of commands to navigate the text file. Even so, using this can be quite a challenge, so here are a few shortcuts to help you out.

Installation

To install Nano simply type in the following command;

Sudo apt install Nano

Accessing Files

Accessing files is very simple, an example of how to open a file would be;

Nano [FileDirectory]

Please be aware that you may need to provide superuser privileges to edit certain files (sudo). A working example of this would be;

Sudo nano /etc/passwd

Interface

Once you have opened your file you will be able to edit text like any other editor, however carrying out more intricate commands can be a bit difficult. Below are a few useful commands to help get you started;



Command Description
Ctrl + X Exit (with option to save)
Ctrl + O Write to file (Save)
Ctrl + W Locate Text in file
Ctrl + R Read in text from another file
Ctrl + K Cut selected text
Ctrl + U Undo cut text
Ctrl + Z Send editor to background

To re-open the session you send to the background using Ctrl + Z simply type the following command to see background jobs;

jobs

You now want to re-open your job, this can be done by typing ‘fg [job number]’. In my case I would type in;

fg 2

Still need help? Open a support ticket

Got any questions? Contact us today.