Level 1
0 / 100 XP

The Nano Editor

By the end of this lesson, you will be able to use Nano, a simple and user-friendly text editor, for basic text editing tasks in a Linux operating system.

What is Nano?

Nano is a command-line text editor that comes pre-installed on many Linux operating systems. It is known for its simplicity and ease of use, making it a great choice for beginners and experienced users alike.

Opening Nano

To open a file using Nano, open your terminal and type the following command:

nano text.txt

Replace text.txt with the name of the file you want to edit or create. If the file does not exist, Nano will create it for you.

__

The entire list of GNU Nano shortcuts and commands can be found here: https://www.nano-editor.org/dist/latest/cheatsheet.html

Basic Navigation

Once you have a file open in Nano, you can navigate through it using the following keyboard shortcuts:

  • Arrow Keys: Move the cursor up, down, left, or right.
  • Page Up/Page Down: Scroll through the file.
  • Ctrl + A: Move to the beginning of the line.
  • Ctrl + E: Move to the end of the line.
  • Ctrl + Y: Scroll up one page.
  • Ctrl + V: Scroll down one page.

Editing Text

To start editing text in Nano, simply type. Here are some essential editing commands:

  • Backspace/Delete: Remove characters to the left of the cursor.
  • Ctrl + K: Cut (delete) from the cursor position to the end of the line.
  • Ctrl + U: Paste contents of the cut buffer
  • Ctrl + O: Save changes to the file (Write Out).
  • Ctrl + X: Exit Nano. If there are unsaved changes, Nano will prompt you to save them before exiting.

Search and Replace

Nano allows you to search for text within your file and replace it:

  • Ctrl + W: Search for text forward.
  • Ctrl + Q: Search for text backward.
  • Alt + R Start a Search and replace session.

Command Help

If you ever forget the…