Website Vidya
Linux & ServersStep-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
Rajesh RayLead 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.

Advertisement

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.

Advertisement

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.

Advertisement

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 + Wto 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.

RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

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

Linux & Servers•

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
Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout