nano Introduction
Linux Commands - Shells

This course is in a series of mini-courses to help you with Bash Shell Scripting.  It is divided into several sections as you can see below.  In addition, to help you in the challenge of learning bash shell scripting you will find a quiz at the end of each mini-course.

Bash Shell: Basics
Bash Shell: vi Text Editor

Bash Shell: Nano Text Editor
Bash Shell: Scripting Basics
Bash Shell: Regular Expressions
Bash Shell: Text Filters


The third  course will help you understand the basics of working with the nano text editor in Linux.  At some time everyone who uses Linux will need a text editor.  .  So whatever, text editor you choose be sure you load it and use it before you need it.


Lesson 2


Course Difficulty
The course level is for the inexperienced Linux User / Administrator.  The focus is to provide a foundation for using basic text editors.

Course Outline
nano Introduction
nano Create Text
nano Help
nano Color
nano Movement
nano Append a File
nano Spellcheck
nano Statistics
nano Search
nano Quiz

 



Nano is an alternative text editor. The  key sequences in nano are entered using the keyboard, making nano  a "modeless" editor, unlike vim. With the exception of Control and Meta key sequences, all the keys will enter text into the file being edited.  You do not have to switch modes at all.  In addition, nano provides some text aids.

The 2.0 release enhances the usability and features of nano. Centos still used version 1.3.

UTF-8 support
Improved color syntax highlighting
Copy text without cutting
Verbatim input mode
Repeat last seach w/o confirmation (Meta-W)
Spell check/replace selected text only
Indent marked text
Move to beginning/end of paragraph
Search within the file browser
Mixed file format auto-conversion

Opening Screen
When you issue the nano command without any options the program opens as you see below with basic command available using Ctrl+Letter(the ^ symbol represents the Ctrl key).

This is version 2.0.7 which you will see on Ubuntu / Debian machines but CentOS will still be using 1.3.12.

nano text editor

When you view the titlebar at the top of the editor you can see the version on the left.  The center of the titlebar shows the name of the file or indicates a "New Buffer", meaning the file has not been named yet.  The right section of the titlebar will indicate if the file has been modified, so that you will recognize you will need to save the changes.

GNU nano 2.0.7                New Buffer                                      

Each of the available key commands needs to be preceded with the Ctrl key.


^G Get Help    ^O WriteOut    ^R Read File   ^Y Prev Page   ^K Cut Text      ^C Cur Pos
^X Exit            ^J Justify          ^W Where Is   ^V Next Page  ^U UnCut Text  ^T To Spell

 

Basic Commands
^G get help
Main nano help text
The nano editor is designed to emulate the functionality and ease-of-use of  the UW Pico text editor.  There are four main sections of the editor.  The top  line shows the program version, the current filename being edited, and whether  or not the file has been modified.  Next is the main editor window showing the  file being edited.  The status line is the third line from the bottom and  shows important messages.  The bottom two lines show the most commonly used  shortcuts in the editor.

^O write the file
If you write text you may write to a file with this command.
File Name to Write: newfile

^R read a file
When you would like to open a file use this command and then supply the path or if it is in your path the filename.
File to insert [from ./] : /home/mike/newfile

^Y previous page
^K cut text
^C current position
This will provide information about the current position.  In this example of viewing the /etc/passwd file, you will see the status line at the bottom.

klog:x:103:104::/home/klog:/bin/false
hplip:x:104:7:HPLIP system user,,,:/var/run/hplip:/bin/false
avahi-autoipd:x:105:113:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/bin/fal$
gdm:x:106:114:Gnome Display Manager:/var/lib/gdm:/bin/false
pulse:x:107:116:PulseAudio daemon,,,:/var/run/pulse:/bin/false
messagebus:x:108:119::/var/run/dbus:/bin/false
avahi:x:109:120:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false
polkituser:x:110:122:PolicyKit,,,:/var/run/PolicyKit:/bin/false
haldaemon:x:111:123:Hardware abstraction layer,,,:/var/run/hald:/bin/false
mike:x:1000:1000:mike,,,:/home/mike:/bin/bash
sshd:x:112:65534::/var/run/sshd:/usr/sbin/nologin

[ line 31/33 (93%), col 1/46 (2%), char 1402/1498 (93%) ]

^X exit
^J justify

^W where is
If you need to search a document you can use this command.  In this example the request is for the user mike and this is the output.
klog:x:103:104::/home/klog:/bin/false
hplip:x:104:7:HPLIP system user,,,:/var/run/hplip:/bin/false
avahi-autoipd:x:105:113:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/bin/fal$
gdm:x:106:114:Gnome Display Manager:/var/lib/gdm:/bin/false
pulse:x:107:116:PulseAudio daemon,,,:/var/run/pulse:/bin/false
messagebus:x:108:119::/var/run/dbus:/bin/false
avahi:x:109:120:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false
polkituser:x:110:122:PolicyKit,,,:/var/run/PolicyKit:/bin/false
haldaemon:x:111:123:Hardware abstraction layer,,,:/var/run/hald:/bin/false
mike:x:1000:1000:mike,,,:/home/mike:/bin/bash


^V next page, scroll through pages
^U uncut text or paste
^T spell check

 

 


Copyright CyberMontana Inc. and BeginLinux.com
All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874