ITD351 Lab 7 Nano Linux Ed
ITD351 Lab 7 Nano Linux Ed
Introduction to nano
The Nano editor is a simple, display-oriented and free text editor that comes by default with
all Linux operating systems. It is a good alternative to the non-free Pico which comes by
default with the Pine package. The programs such as Vi and emacs might be more powerful,
but the smart feature set of Nano makes it easy to learn and use for beginners. Text insertion
and navigation through the files is pretty straightforward and involves only typing the text
and basic cursor movement.
Nano for Linux is a Terminal-based text editor so first, you will need to open the Terminal
window. Once you have opened the Linux Terminal you can open Nano by using the
following command:
$ nano
You will see the following screen with a new buffer/file open:
As you can see above, the editor is divided into four main sections:
The first line at the top displays version number of Nano, the filename (in this case no filename has
been specified yet) and whether the file has been modified or not.
A line above the shortcuts, displayed at the bottom, shows system messages such as status information
from the system.
The two shortcut lines at the bottom provide the user with a set of most commonly used shortcuts.
2 Creating a File
In order to launch Nano and create a new file to work on, use the following command:
$ nano filename
The image below shows a file named filename.txt that we have created to work around for
practice.
3 Opening a File
You can open an already existing file by using the following command:
$ nano [file-name]
This command will open the file if it exists in your current directory. You will have to specify
the entire location path if the required path exists elsewhere in your storage.
In order to cut the selected text, press ctrl+k and then position the cursor where you want to
paste the text. Now press ctrl+u; you will be able to see the text pasted to this position.
In this example, we have selected the text “This is some more sample text.” and copied it
down the document through ctrl+u.
Note: Use the Alt+^ shortcut to copy the text instead of cutting in.
Now place the cursor on the position where you want to paste the string and press ctrl+u.
You can see the string has been pasted to a new location in the following image:
10 Saving a file
In order to save a file, please use the ctrl+o shortcut. Nano will ask you to enter a file name
or re-confirm the file name if you have already specified it. Make the required changes and
hit enter; your file will be saved to the system.
The status bar will show the number of lines saved in your file as follows:
In the following image, the selected line has been inserted from the specified file.
Switch Purpose
nano -B Use this switch in order to back-up the file before editing it.
nano -E Use this switch in order to convert tabs to spaces when editing your text.
nano -c Use this switch in order to view the cursor position stats continuously.
Use this switch in order to automatically indent new line(s) with the same position as
nano -i the previous line.
Use this switch in order to toggle cut (It cuts from the cursor position instead of
nano -k cutting the entire line of text.
You are now able to create, edit and save Nano files after practicing along with this article.
With the help of Nano’s power ful shortcuts, you can easily edit your files such as cut, copy
and paste text, spell check your file, copy text from another file etc.