Search The Hostwinds Guides Knowledge Base

How To Use Nano Editor (Linux)

Share This Article [TheChamp-Sharing]

Nano editor and how to use this text editor to edit files on your server is what we will cover in this guide. Nano is found on most Linux distributions and is easy to use with its most often used commands shown at the bottom of its screen. As editing configuration and other files is a very common task in Linux; knowing how to use this program can be quite useful.

Commands in nano are begun with the CTRL key and usually followed by a letter. Within the nano program the CTRL key is shown as a ^ symbol at the bottom of its screen like this:

As indicated in the above image, you can also press CTRL G to view nano’s help page.

Here are some examples of usage:

Open File

To open a file for editing you would type nano at the command line followed by the filename:

nano somefile
or
nano /etc/hostname

Create File

To create a new file you would type nano at the command line, with or without the file name you wish to use:

nano
or
nano mynewfile

If you don’t enter the filename it will open a blank file and you will be asked for the filename when saving it.

Save File

To Write Out or Save the file you have been editing press CTRL O. It will then prompt you for the filename to save as.

Hit the enter key when done.

Exit File

When you are done editing the file type CTRL X to close the file. If you have made any changes to the file you will be prompted to save or discard those changes. If you haven’t made any changes to the file the editor will just close, returning you to the command-line again.

Related Articles