FactorPad
Build a Better Process

Linux nano Command Summary with Examples

Linux nano allows you to edit text files.
  1. Purpose - Learn what nano is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with nano.
  4. A tip - Finish off with one more insight.
face pic by Paul Alan Davis, CFA
Updated: February 23, 2021
In this tutorial on Linux nano, 20 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / nano-command.html


An ad-free and cookie-free website.


Examples of the Linux nano Command

Beginner

Learn to edit text files at the Linux command line.

Video Tutorial

Videos can also be accessed from the Linux Essentials Playlist on YouTube.

Linux nano Command Summary with Examples (3:54)

Video Script

The Command and Why You Need It

Our twentieth word, or command to memorize is nano from the category Text.

nano allows you to edit text files.

Common Linux nano Options
-options description
-h, -?, --help Print help screen
-v, --view Open in read-only mode

Recall from the last video (tutorial) we saw how echo displays text, but to edit text we need a distinct program, similar to a word processor, and for that we'll use nano.

Before we start, it helps to think about commands as mini programs and most follow this structure: command -option(s) argument(s).

The nano command has over 30 options and the argument is the text file you'd like to edit.

Like most commands, help is available and for nano it is quite concise.

Options like -v, set the options going into the program. Instead of expanding on them during this short time, it's best to spend the time within nano.

So why is nano an important command? Well, nano is widely available and is the easiest way to edit text. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go, let's type nano and a text file that I copied from video five.

$ nano video20.txt

There we opened it in less, which is just a file viewer, not an editor like nano.

GNU nano 2.2.6 File: video20.txt This is the first line This is the second line This is the thrid line This is the fourth line This is the fifth line # A file for video 5 on less to demonstrate the -N option [ Read 7 lines ] ^G Get Help ^O Write Out ^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

See how we're sitting within a separate program, not at the command prompt? And nano has its own functionality. See the control-keystroke combinations here like Ctrl-X to exit.

Next, let's move this comment up here, to where it belongs, arrow down Ctrl-K to Cut, arrow up, Enter a line, UnCut, or paste, using Ctrl-U, then edit the text so it is a more accurate comment.

GNU nano 2.2.6 File: video20.txt # A file for video 20 on nano This is the first line This is the second line This is the thrid line This is the fourth line This is the fifth line [ Read 7 lines ] ^G Get Help ^O Write Out ^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

Now let's Ctrl-x to leave. It verifies if you want to save, y and Enter to over-write. Please note, either upper or lowercase works here to leave.

A Final Tip

Okay now you know how to use nano. And you know the syntax for commands, options and arguments.

One last tip about the nano command. Run a whatis command on nano, and in our next video we'll clear up the confusion about pico.

Okay, thanks for visiting today. I hope this was a fun introduction to the nano command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

The goal is to make learning faster by combining video and text tutorials, so to catch the latest video, subscribe now. Also, follow @factorpad on Twitter for notifications.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / nano-command.html


linux nano command
nano text editor
edit text files
linux nano how to
nano command syntax
nano command summary
linux nano options
linux nano tutorial
linux nano video
nano code editor
nano configuration files
unix nano

A newly-updated free resource. Connect and refer a friend today.