Using nano on the command line

Introduction

The nano text editor is a very lightweight text edit for reading and editing plain text files from within a shell window. Other alternatives are pico (which is even more lightweight) and the big kahunas vi and emacs. If you just need to page through a file to read it, consider using more or less which are designed for navigating rather than editing. Whatever your final choice, and even if you end up preferring a desktop editor like Textwrangler, Notepad++, or gEdit, you really need to get proficient in one editor - it may be the difference between success and failure someday.

Using nano

Start by creating a test file in the nano editor: nano test.htm. You will see something resembling the following:

The first thing you may notice is the "GNU nano 1.3.12" in the upper left corner. GNU Nano 1.3.12 is telling you the program and it's version. In the center of the top bar it tells you what file you are editing. At the bottom of the screen you should see a bunch of commands. The caret (^) signifies holding down the 'Control' key and typing the letter. For example 'Control g' (^G) with display a Help file with a bunch of information about using nano. 'Control x' (^X) will exit the program and return you to the prompt. 'Control o' (^O) or (f3) will write or save the file to the Lonestar's file system. Finally, you should see a prompt just below the "GNU nano 1.3.12" text. This is where you can begin typing.

This is test file we are creating for tutorial purposes. Now we want to write (save) the file. We do this by holding down the 'Control' key and pressing 'o' or the function key 'F3'.

Notice how the screen has changed down at the bottom left. Nano is now asking you if you want to save this file with this name. If you do, please press 'Enter'. If you do not, either press 'Esc' or enter the name you want the file named as.

You can now see at the middle bottom of the screen it says "[ Wrote 5 lines ]". This is the number of lines in the test.html file written to disk.

The last step is to quit nano by hitting 'Control x'. If everything has gone well, you should be back at the command prompt.

Supplemental information