Nano Editor Installation and Usage Guide on AlmaLinux, Rocky Linux, CentOS, RHEL, Ubuntu, and Debian

Introduction

Nano is one of the most popular command-line text editors available on Linux systems. It is lightweight, beginner-friendly, and installed by default on many Linux distributions. System administrators and developers frequently use Nano to edit configuration files, scripts, cron jobs, and server settings directly from the terminal.

In this guide, you’ll learn how to install Nano Editor on AlmaLinux, Rocky Linux, CentOS, RHEL, Ubuntu, and Debian, as well as how to use its most important features efficiently.


What is Nano Editor?

Nano is a terminal-based text editor designed to provide a simple and intuitive editing experience. Unlike Vim or Emacs, Nano does not require memorizing complex commands, making it an excellent choice for beginners and experienced Linux users alike.

Key Features

  • Easy-to-use interface
  • Lightweight and fast
  • Syntax highlighting support
  • Search and replace functionality
  • Mouse support
  • File backup options
  • Multi-buffer editing

Installing Nano on AlmaLinux, Rocky Linux, CentOS, and RHEL

Most modern Enterprise Linux distributions use the DNF package manager.

Update Package Repositories

sudo dnf update -y

Install Nano

sudo dnf install nano -y

Verify Installation

nano --version

Example output:

GNU nano, version 7.x

Installing Nano on Ubuntu and Debian

Update Package Index

sudo apt update

Install Nano

sudo apt install nano -y

Verify Installation

nano --version

Opening a File with Nano

To create or edit a file:

nano filename.txt

Example:

nano notes.txt

If the file does not exist, Nano will create it automatically when saved.


Understanding the Nano Interface

When Nano opens, you’ll see:

  • File content area
  • Status bar
  • Shortcut menu at the bottom

The shortcuts displayed use the following notation:

  • ^ = Ctrl key
  • M = Alt key (Meta key)

Example:

^X Exit
^O Write Out
^W Where Is

Basic Nano Commands

Save a File

Press:

Ctrl + O

Then press:

Enter

to confirm the filename.


Exit Nano

Press:

Ctrl + X

If unsaved changes exist, Nano will ask whether to save them.


Cut a Line

Ctrl + K

Paste Text

Ctrl + U

Search Text

Ctrl + W

Enter the search term and press Enter.


Search and Replace

Press:

Ctrl + \

Enter:

  1. Search string
  2. Replacement string

Choose whether to replace individual matches or all occurrences.


Go to a Specific Line

Ctrl + _

Enter the line number.

Example:

125

Nano jumps directly to line 125.


Working with Configuration Files

System administrators often use Nano for editing Linux configuration files.

Examples:

SSH Configuration

sudo nano /etc/ssh/sshd_config

Hosts File

sudo nano /etc/hosts

Crontab

crontab -e

You can configure Nano as the default editor if prompted.


Enable Syntax Highlighting

Modern Nano versions support syntax highlighting.

Edit Nano configuration:

sudo nano /etc/nanorc

Uncomment or add:

include "/usr/share/nano/*.nanorc"

Save and restart Nano.

You will now see colored syntax for:

  • Bash scripts
  • Python
  • PHP
  • HTML
  • CSS
  • JavaScript
  • JSON
  • YAML
  • Configuration files

Creating Backup Files Automatically

Edit the Nano configuration file:

nano ~/.nanorc

Add:

set backup

Nano will automatically create backup files whenever changes are saved.

Example:

config.conf~

Display Line Numbers

Add the following to your Nano configuration:

set linenumbers

This is particularly useful when editing scripts and server configuration files.


Useful Nano Keyboard Shortcuts

ShortcutFunction
Ctrl + OSave file
Ctrl + XExit Nano
Ctrl + KCut line
Ctrl + UPaste line
Ctrl + WSearch
Ctrl +
Search and replace
Ctrl + GHelp
Ctrl + CShow cursor position
Ctrl + _Go to line
Alt + UUndo
Alt + ERedo

Common Troubleshooting

Nano Command Not Found

If you receive:

nano: command not found

Install Nano using your distribution’s package manager as shown earlier.


Permission Denied

If editing system files:

sudo nano /path/to/file

Administrative privileges are required for protected files.


Nano vs Vim

FeatureNanoVim
Beginner FriendlyYesNo
Easy CommandsYesModerate
Learning CurveLowHigh
Advanced FeaturesBasicExtensive
Ideal for Quick EditsExcellentGood

For most server administration tasks, Nano is often the fastest editor to use.


Conclusion

Nano remains one of the best text editors for Linux administrators, developers, and beginners. Its simple interface, powerful editing capabilities, and availability across nearly all Linux distributions make it an essential tool for managing configuration files and performing quick edits from the terminal.

Whether you’re running AlmaLinux, Rocky Linux, CentOS, RHEL, Ubuntu, or Debian, Nano provides a reliable and efficient editing environment directly from the command line.

Scroll to Top