Website Vidya
DeploymentStep-by-Step Guide

How to Install Nano Text Editor on Ubuntu

Nano text editor comes up with many powerful features. It allows you to create and edit various files on your Linux based computers or server. It is considered as the most easiest tool for editing. In this tutorial, we will see how to insta...

RR
Website Vidya TeamLead Systems Educator
Published:
6 min read
How to Install Nano Text Editor on Ubuntu
AI Executive SummaryCORE CIS AI

6 min read

Nano text editor comes up with many powerful features. It allows you to create and edit various files on your Linux based computers or server. It is considered as the most easiest tool for editing. In this tutorial, we will see how to insta...

Key Highlights
  • Features
  • Prerequisite
  • How to Install Nano Text Editor
Grounded in full engineering runbookCORE CIS Ai Engine

Nano text editor comes up with many powerful features. It allows you to create and edit various files on your Linux based computers or server. It is considered as the most easiest tool for editing. In this tutorial, we will see how to install Nano text editor on Ubuntu.

Features

Nano text editor is suitable for both beginners and advanced users. Nano text editor allows you to copy, paste, select, search and edit the file. Furthermore, there is a bottom bar at the bottom of the editor screen that shows useful shortcuts.

In Nano, you don't have to switch to an edit mode like Vim. You can directly interact with the text.

Prerequisite

Before we learn how to install Nano text editor on Ubuntu, make sure that you have the access to Ubuntu Server.

Now, update your server by running:

sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get autoremove

How to Install Nano Text Editor

To install Nano text editor on Debian or Ubuntu server, execute the following command:

sudo apt-get install nano

With this, you have successfully installed the Nano text editor.

How to Use Nano Text Editor?

In this part, we will learn how to operate Nano text editor by opening, closing, searching and replacing text.

Create a New File

Type nano to open a new blank file. You can press (CTRL+X), text editor will ask whether to save or discard the file. To save modification, press "y", it will ask you to name the file. Type the name of the file and press enter to save the changes.

Similarly, if you press "n" or "c", this will discard changes or cancel any changes made in the file respectively.

Opening and Closing the Nano Editor

Type nano and then the filename to open Nano to edit a certain file.

nano filename

However, to open an existing file in another directory, you must include the path where the file is located.

If you want to edit the default index.php file your website, you can include the path of the default directory of your website and file name with the file extension.

nano /var/www/html/example.com/public_html/index.php

Alternatively, you can also navigate to the default directory of your website and use nano to edit the index.php file.

Search and Replace Command

Press CTRL + W to search in the text. Insert your keyword or string and press Enter. To continue searching for the same keyword, use ALT + W.

If you are aiming to find and replace a text, press CTRL+W to enter the text that you want to search and then replace it by pressing CTRL+R. Now the text editor will take you to the first instance of the text. Now you have two option. Either you can press Y to replace one text or A to replace all the instances.

In case you want to cancel the current process, you can press CTRL + C to discard any changes.

Editing Text

To select text, move the cursor to the beginning of the text and then press Alt+a. This command will set mark for selection. Now, with the help of the nudge keyys (arrow keys) move the cursor till the end of the text you want to select. This will highlight the selected text.

In case you want to cancel the selection press Ctrl+6

Press Alt+6 to copy the selected text to the clipboard.

Ctrl+k will cut the entire selection of text.

Now move the cursor to the line and press Ctrl+k to cut whole lines. To cut multiple lines, press Ctrl+k repeatedly.

Nano Text Editor Commands Shortcuts

CommandDescription
CTRL + ATo jump to the beginning of the line.
CTRL + ETo jump to the end of the line.
CTRL + YTo scrolls down the page.
CTRL + VTo scrolls up the page.
CTRL + GTo see the help window that will help you with all the available commands.
CTRL + OTo save the file. The Nano text editor will ask you to edit or verify the file name that you want to keep.
CTRL + WThis command will help you search for any specified phrase in your text. You can press ALT + W to continue searching for the same phrase.
CTRL + KThis will cut the entire selected line to the cut buffer (similar to clipboard).
CTRL + UIt is used to paste the text from the cut buffer into the selected line.
CTRL + JIt is used to justify the current paragraph.
CTRL + CIt shows the current cursor position in the text (line/column/character).
CTRL + RIt opens a file and inserts it at the current cursor position.
CTRL + XTo exit Nano text editor. Once you press this command, nano will prompt a save request in case you have made any changes inside file.
CTRL + \It replaces the string or a regular expression.
CTRL + TThis command will Invoke the spell checker, if it's available.
CTRL + _It helps you go to the specified line or column number.
ALT + ATo select text. You can combine this command with several other commands to perform certain actions.

You may also want to check out nano Command Manual.

How to Remove/Uninstall Nano Text Editor from Ubuntu?

Simple Nano Uninstall

To uninstall the Nano text editor, you just need to follow the given instructions:

sudo apt-get remove nano

This will remove just the nano package itself.

Uninstall nano and its dependencies

To uninstall nano and its dependencies, run:

sudo apt-get remove --auto-remove nano

This command removes the nano package and any other dependencies that are no longer required. This will help you free up the space in your machine or server.

Purging your config/data too

If you want to delete your local/config files for nano, you can run:

sudo apt-get purge nano

or

sudo apt-get purge --auto-remove nano

Caution! Purged config/data can not be restored by reinstalling the package.

Conclusion

We successfully learnt how to install Nano text editor on Ubuntu with it's uses. We also covered some useful commands and editing tips to improve the workflow while working on Ubuntu Linux.

At the very end, we also covered how to uninstall Nano text editor on Ubuntu.

I hope you would find this tutorial useful. Do put your feedback in the comment section below.

Also, let me know about the topics that you want to learn more about.

Good luck, and be sure to check our other resources on Server and Deployment.

Written by

Website Vidya Team

Technology educator and researcher at Website Vidya.

Discussion

0
Share your thoughts, ask a question, or suggest a tip...
Write →

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Deployment•

How to Install PDO Extension in PHP

PHP Data Objects (PDO) is one of the most important extensions in PHP for working with databases in a secure, consistent, and modern way. If you are building dynamic websites, APIs, CMS platforms, or enterprise applications, PDO is not opti...

RR
Rajesh Rai
Read More
Deployment•

How to Install PHPMyAdmin on Ubuntu: 4 Simple Steps

If you’re working with MySQL or MariaDB on Ubuntu, managing databases purely from the command line can quickly feel overwhelming. That’s where phpMyAdmin comes in. PHPMyAdmin is a web-based application that provides a Graphical User Interfa...

RR
Rajesh Rai
Read More
Deployment•

25 Best Linux Commands Every Sysadmin Should Know

If you’ve spent any time managing Linux servers, you already know this truth: the command line is not optional. It’s where real troubleshooting happens, where performance issues are understood, and where outages are prevented before users e...

RR
Rajesh Rai
Read More
Deployment•

How to Fix Snapd Consuming High CPU / RAM on Linux

If you’ve ever opened your system monitor and noticed snapd quietly eating up your CPU or RAM, you’re not alone. Many Linux users—especially on Ubuntu and Ubuntu-based distributions—eventually run into this issue and wonder what’s going on ...

RR
Rajesh Rai
Read More
Deployment•

How to Fix Broken Packages in Ubuntu: 7 Simple Ways

If you’ve been using Ubuntu for a while, chances are you’ve run into package-related issues at least once. A failed update, an interrupted installation, or conflicting dependencies can easily leave your system in a messy state. When that ha...

RR
Rajesh Rai
Read More