Install Nano & Supercharge Your Linux Text Editor Experience

Try this guide with our instant dedicated server for as low as 40 Euros

Install Nano

GNU nano (more commonly known as Nano) is a popular text editor bundled in almost all major Linux distributions.

It is known for its simplicity and ease of use. In Linux environments, it is a popular choice among users, especially those who prefer a straightforward text editing experience without the complexity of more advanced editors like Vim or Emacs.

Whether modifying configuration files and saving them to the disk, writing scripts, or taking notes, Nano offers a user-friendly interface that makes text editing a breeze as a command-line editor.

In this comprehensive introduction to the Nano editor, we will discuss several aspects of working with the editor. We will start with how to install Nano package on your system and then move on to basic Nano skills, such as the keyboard shortcuts.

Table of Contents

  1. Install the Nano Text Editor
    1. Debian/Ubuntu-based Distributions
    2. RHEL/Fedora/CentOS-based Distributions
  2. How to Use Nano Editor for File Management in Linux
    1. Create a New File With Nano
    2. Open an Existing File with Nano
    3. Modifying Files with Nano
  3. Essential Nano Editor Keyboard Shortcuts
  4. Writing to a File Using the Nano Editor
    1. List of Shortcut Keys
  5. Conducting Text Searches
    1. Utilize Regex for Advanced Searches
  6. Replacing Text
  7. Correcting Text with Spell Checking in Nano
  8. File Management in Nano: Saving and Exiting the File
  9. Conclusion
  10. FAQ’s

Install the Nano Text Editor

Given its popularity, Nano comes pre-installed as a part of the standard package lineup of popular Linux distros.

However, you may find it missing from your system because the distribution maintainers might opt for another editor as the system’s default.

In this case, you can easily install it on the system by executing a simple two-step procedure.

Launch the terminal and refresh the system’s package index. This preparatory step ensures you have the latest and most stable versions of software. For this, run the following command:

# apt update

Next, we can proceed to add Nano to the system by running the appropriate command for your distribution:

Debian/Ubuntu-based Distributions

Run the following command to install Nano on your Debian-based distributions:

# sudo apt install nano

RHEL/Fedora/CentOS-based Distributions

Run the following command to install Nano on your RHEL=based distributions:

# yum install nano

Once the command finishes, you can launch Nano by invoking the editor in the terminal:

Install the Nano Text Editor

# nano

As you can see, Nano offers a simple interface that allows you to focus on text creation and editing.

How to Use Nano Editor for File Management in Linux

One of the reasons behind Nano’s popularity is its wide array of operations, including opening, creating, and editing files.

Let’s briefly discuss the three critical file management operations in Nano.

Create a New File With Nano

Creating a file with Nano is a simple process. Start by launching the editor in the terminal.


You will see a blank screen with menu options at the bottom. You can now enter your content and then exit the editor with Ctrl+X. Nano will inquire if you wish to retain or discard your modifications.

If you opt to save the changes by pressing Y, Nano prompts for a filename. Upon entering your preferred name (such as file1.php), and hitting Enter, your file is successfully saved.

Create a New File With Nano

Do you know that exiting Vi and Vim is slightly more tricky? We have a simple tutorial that shows you how to save your work and exit Vi and Vim editors.

Open an Existing File with Nano

Editing files is a frequent task in system administration. Nano simplifies this task by offering a smooth editing experience.

To edit a pre-existing document, simply append the filename to the nano command. For instance, if you need to edit a file named file1.php, run the following command in the terminal:

# nano file1.php

Note that this assumes that the file is in the current working directory. For files in other directories, it’s essential to include the full path to the file in your command. The syntax is as follows:

# nano /home/files/file1.php

While launching Nano for editing files, you can leap straight to a designated line and column within a file using the following command format:

# nano +line, column filedemo1

Modifying Files with Nano

Nano’s appeal lies in its straightforward graphical user interface (GUI), which eliminates the need for a separate edit mode, unlike editors such as Vim.

This feature allows for direct interaction with the text, enabling users to effortlessly write, amend, and navigate through the content while receiving real-time visual feedback. This intuitive interface makes Nano an accessible and efficient tool for users of all proficiency levels.

Essential Nano Editor Keyboard Shortcuts

The real power of Nano lies in its amazing list of keyboard shortcuts. These shortcuts primarily involve the Control (Ctrl) key, depicted in Nano’s interface with a caret symbol (^) followed by an alphabetical character.

For instance, to exit Nano, the keyboard shortcut is Ctrl+X, which is visually represented within the editor as ^X. Consider the following image that shows the bottom menu that shows some of these shortcuts.

Essential Nano Editor Keyboard Shortcuts

Nano also offers shortcuts that utilize the Meta key, which is typically the Alt key on most keyboards. These shortcuts are indicated by an M preceding a character.

A common example of such a shortcut is Alt+U for undoing the last action, denoted within the Nano interface as MU.

Nano thoughtfully displays a selection of these important shortcuts in the bottom two lines of the editor window, providing easy access to frequently needed commands for an enhanced editing experience.

Nano provides on-demand help you can access by Ctrl+G (indicated as ^G) or the F1 key. This action will launch the help documentation within Nano, detailing every applicable keystroke for efficient navigation and editing.

Writing to a File Using the Nano Editor

When working with large documents within Nano, you need to know the quick navigation shortcuts to enhance your editing efficiency. Nano supports both arrow key movements and a set of keyboard shortcuts for rapid text traversal.

List of Shortcut Keys

When working with large files, the following keyboard shortcuts can help you quickly move through the document.

  • Advance by one character: Use Ctrl+F (^F)
  • Retreat by one character: Use Ctrl+B (^B)
  • Jump forward by a word: Use Ctrl+Space (^Space)
  • Jump backward by a word: Use Alt+Space (M-Space)
  • Ascend to the previous line: Use Ctrl+P (^P)
  • Descend to the next line: Use Ctrl+N (^N)
  • Scroll down a page: Use Ctrl+V (^V)
  • Scroll up a page: Use Ctrl+Y (^Y)
  • Leap to the start of the line: Use Ctrl+A (^A)
  • Move to the line’s end: Use Ctrl+E (^E)

Conducting Text Searches

Searching for specific characters and words is another critical aspect of working with text files.

Nano comes with a dedicated where is function, activated by the Ctrl+W (^W) shortcut. This reveals a search field where you can enter your query. When you press Enter, the first instance of the query will be highlighted. Now, you can press Alt+W (M-W) to cycle through the other occurrences of the query.

Conducting Text Searches

You can mention a particular line by using Ctrl+T (^T) within the search interface and input the desired line number.

Utilize Regex for Advanced Searches

Nano also accommodates Regex (regular expressions) for complex search patterns. This function is different from the standard search. You can access the regex pattern with Alt+R (M-R), allowing pattern-based searches.

Searching for text is also a simple process in Vi and Vim. We covered four example scenarios of using search in Vi and Vim.

Replacing Text

To substitute text within your document, initiate the search function with Ctrl+W (^W), followed by Ctrl+R (^R) to bring up the replacement prompt. Here, you can input the target text for substitution, streamlining the editing process.

Correcting Text with Spell Checking in Nano

Nano enhances your text editing experience with built-in spell-checking functionality. To access this feature, it’s essential first to ensure the spell checker is installed on your system.

Start by installing the spell checker package by executing the following command:

# apt install spell.

Once the spell package is successfully installed, activating the spell check within Nano is straightforward. Simply press Ctrl+T (^T) during editing sessions. This shortcut will highlight any potentially misspelled words within your document, prompting you to enter the correct spelling for each identified mistake.

As you proceed with the spell check, Nano will underline words it perceives as incorrect, guiding you through reviewing and correcting your text to achieve polished and error-free content.

File Management in Nano: Saving and Exiting the File

In Nano, saving your work is a straightforward process that you can initiate with the keyboard shortcut Ctrl+O (^O).

Upon activation, Nano prompts you to specify a file name for new files or confirm the name for existing ones. Following a successful save, the editor’s status bar updates to reflect the total line count of the document, providing immediate feedback on the file’s length.

Nano can optionally maintain backup versions of your files, adding an extra layer of security for your data. This is achieved through the Alt+B (notated as M-B) shortcut. Triggering this command toggles the backup feature on and off, allowing you to easily manage temporary copies of your work for added peace of mind.

When it’s time to conclude your editing session, exiting Nano is as simple as pressing Ctrl+X (^X), which is clearly indicated within the editor’s interface. This command closes the editor, bringing you back to the terminal prompt, effectively concluding your Nano session.


Mastering the Nano text editor in Linux begins with the simple step of ensuring its presence on your system, often achieved with the ‘install nano’ command.

This lightweight yet powerful editor offers a suite of features that cater to both novice and experienced users, providing an intuitive interface for editing text files, configuring system settings, or coding.

From basic file management to advanced functionalities like search and replace, spell checking, and text selection, Nano is a great option for efficient text manipulation.

Whether you’re just starting out with Linux or looking to refine your editing skills, Nano offers a user-friendly platform to enhance your productivity and simplify your workflow.

At RedSwitches, we take pleasure in assisting our valued customers with their unique server needs. Our range of customizable bare metal servers is designed to provide you with reliable server infrastructure for your projects. We understand the importance of competitive pricing, and that’s why we offer dedicated server options at affordable rates. When you choose us, you can expect a seamless experience as we prioritize swift delivery, typically fulfilling orders approved on the same day. Whether you require a dedicated server, a traffic-friendly 10Gbps dedicated server, or a high-performance bare metal server, we are here to be your trusted hosting partner.


Q. What is Nano, and how do I open it in Linux?

Nano is a simple, user-friendly text editor for Unix and Linux operating systems. To open Nano, you can type nano followed by the name of the file you wish to edit (e.g., nano filename.txt) in the terminal. If the file doesn’t exist, Nano will create it upon saving.

Q. How can I save changes made in a Nano editor session?

To save changes in Nano, press Ctrl + O. This command will prompt you to confirm the file name. Press Enter to confirm and save the changes to the current file.

Q. What is the shortcut for exiting Nano, and how does it handle unsaved changes?

To exit Nano, press Ctrl + X. If there are unsaved changes, Nano will ask whether you wish to save them. You can respond with Y for yes to save and exit, N for no to exit without saving, or Ctrl + C to cancel the exit command and return to editing.

Q. Can I search for text within a Nano document? How?

Yes, to search for text within a Nano document, press Ctrl + W and then type the text you’re searching for. Press Enter to initiate the search. Nano will jump to the first occurrence of the text.

Q. How do I cut, copy, and paste text in Nano?

Cut: Place the cursor at the beginning of the text you want to cut, press Ctrl + ^ (Ctrl and caret, which is usually Shift + 6), then move the cursor to the end of the text, and press Ctrl + K.

Copy: Nano does not have a direct copy command, but you can use the cut command without deleting. Cut the desired text and then immediately paste it back.

Paste: Place the cursor where you want to paste the text and press Ctrl + U.

Q. How can I enable line numbering in Nano?

To enable line numbering, you can start Nano with the -l or –linenumbers option (e.g., nano -l filename.txt). Alternatively, you can turn on line numbering during editing by pressing Alt + Shift + 3.

Q. Is it possible to indent or unindent a text block in Nano?

To indent a block of text, highlight it using Ctrl + ^ and the arrow keys, then press Alt + } to indent. To unindent, use Alt + {.

Q. How do I navigate to a specific line or column in Nano?

To go to a specific line and column, press Ctrl + _ (Ctrl and underscore), then type the line number, a comma, and the column number (e.g., 5,10 for line 5, column 10), and press Enter.

Q. Can I spell-check a document in Nano?

If you have spell or aspell installed on your system, you can spell-check a document in Nano by pressing Ctrl + T. This will invoke the spell checker, highlighting potential misspellings and suggesting corrections.

Q. How do I configure Nano to wrap long lines automatically?

Nano typically wraps long lines by default. However, if line wrapping is disabled, you can enable it by pressing Alt + L during editing or starting Nano with the -w or –no-wrap option to turn off wrapping, then toggling it in the session.

Try this guide with our instant dedicated server for as low as 40 Euros