0% found this document useful (0 votes)
100 views7 pages

ITD351 Lab 7 Nano Linux Ed

This document provides an introduction and overview of using the Nano text editor in Linux. Nano is a simple terminal-based text editor that comes pre-installed with most Linux distributions. It allows users to create, open, edit and save text files. The document outlines how to launch Nano, open and create files, navigate text, copy/cut/paste, spell check, insert files and use various switches. Key shortcuts for common Nano functions are also described.

Uploaded by

Vin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views7 pages

ITD351 Lab 7 Nano Linux Ed

This document provides an introduction and overview of using the Nano text editor in Linux. Nano is a simple terminal-based text editor that comes pre-installed with most Linux distributions. It allows users to create, open, edit and save text files. The document outlines how to launch Nano, open and create files, navigate text, copy/cut/paste, spell check, insert files and use various switches. Key shortcuts for common Nano functions are also described.

Uploaded by

Vin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

ITD351 Big Data Management Essentials

Lab 7 Introduction to nano

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.

ITD351 Lab 7 Linux Fundamentals Page 1


1 Running Nano Editor on Linux

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.

ITD351 Lab 7 Linux Fundamentals Page 2


Note: If you have opened a new file/buffer without naming it by using only the
command “nano”, you can name it while saving the file. Please refer to Saving a
file section for more information.

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.

Working with files


4 Navigating through the file
You can move around your file by using the arrow keys but a quicker way is to use shortcuts
with keyboard letters that are usually available in all environments.

5 Displaying cursor position


Sometimes you will need to know the current position of the cursor within your file. The
shortcut ctrl+c will not only highlight the cursor area but also display location details in the
status line above shortcuts.
6 Placing the cursor on specific line and column at startup

ITD351 Lab 7 Linux Fundamentals Page 3


You can set up the Nano editor for opening an already existing file with the cursor set at a
specific line and column. You can use the following command to specify the line and column
of the file while launching Nano:

$ nano +line,column [filename]

7 Copying, cutting and pasting text


Let us start with writing some sample text that we can select, cut or copy and paste in our file.
Selecting the text is very simple in Nano; bring the cursor to that text and select through
keyboard or mouse controls.

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.

ITD351 Lab 7 Linux Fundamentals Page 4


8 Cutting a string of text
The Nano editor also enables you to cut a string of text instead of the entire line. In the
following example, we will cut the string “sample” from our text. Please select the string that
you want to cut by placing the cursor at the start of the string and pressing ctrl+6. This will
mark the string as selected; the status bar will show the “mark set” message.

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:

ITD351 Lab 7 Linux Fundamentals Page 5


9 Spell checking your text
You can spell check your text by using the control: ctrl+t. Although Nano is not a word
processor, this added feature helps you have an error-free file when it comes to spellings.

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:

11 Inserting one file into another


With Nano, you can merge the contents of one text file to the other. Open a file and
press ctrl+R. The Editor will ask you the file name whose text you want to insert in the
current file. You can see that in the following image we have entered the
filename filnamet.txt.

In the following image, the selected line has been inserted from the specified file.

ITD351 Lab 7 Linux Fundamentals Page 6


12 Useful Switches in Nano
The Nano editor comes with a number of powerful switches. The most common and useful
ones are mentioned below for your use; others can be found in the Nano Editor’s manual:

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.

nano -m Use this switch in order to get mouse support.

nano -v Use this switch in order to open files in read-only mode.

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.

This is the end of the lab

ITD351 Lab 7 Linux Fundamentals Page 7

You might also like