How to Undo & Redo in Linux Nano file Editor

Not much familiar with Linux Nano file Editor, then here are some keyboard shortcuts you can use with it to work around easily such as Undo and Redo options in Nano editor. 

Nano is easy to use and simple text-based file editor. It allows you to edit files in a terminal or console, even without a graphical environment. Although the Nano has a smaller range of functions than VIM or Emacs, it is much easier and more intuitive to use. Nano is therefore particularly suitable for smaller, fast edits or for writing short scripts.

The editor supports syntax highlighting for different programming languages, undo/redo functionality, mouse support (if a graphics server is running), automatic indentation, saving files with MS-DOS or Mac line endings, and much more.

Useful Commands to use Nano Editor on Linux

1. Install Nano

Well, many full-fledged Linux GUI desktops come with nano editor pre-installed, however, if not then we can install it with a default package manager.

For Debian or Ubuntu-based systems

sudo apt install nano

Whereas for Redhat-based ones:

sudo dnf instal nano


2. How to create a file

Once the nano editor is installed on your system, we can create a new file easily using it. Just use the given syntax.

nano new-file-name


nano test


3. How to open a file

Whereas to open an existing file on the system to perform changes, we can rely on Nano editor as well.

nano filename-to-open


4. How to Undo Changes in Nano Editor

If you are editing any file and made some changes that you want to undo before saving the file then that is possible using a simple keyboard shortcut that is: Alt+U

In case Alt+U doesn’t work, you can use Esc+u

Note: Remember you cannot use a regular Ctrl+Z  keyboard shortcut to undo because it will exit the text editor.

How to Undo Changes in Nano Editor


 5. How to Redo Changes in Nano Editor

Well, if you accidentally undo something and want it back then Redo is an option to go with. However, to use it in Nano using a Keyboard shortcut use the combination of Alt+E.  This will get back the last deleted text on your nano editor.


6. Save the file in the Nano editor

If you are new to Nano editor then you may not know the keyboard shortcut to save the file that you either have newly created or made some changes.

To save a file using the Ctrl+O key combination, then hit the Enter key.


7. Exit file

To safely exit the Nano editor after editing the file using the keyboard shortcut combination that is – Ctlr+X. Moreover, if you have made changes to the file, you will be prompted to save or discard those changes. If you haven’t made any changes to the file, Notepad simply closes and returns you to the command line.


Nano is found on most Linux distributions and is easy to use, with the most commonly used commands displayed at the bottom of the screen. Commands in Nano are started with the Ctrl key and are usually followed by a letter. Within the NANO program, the Ctrl key at the bottom of the screen appears as an icon.

Commands in Nano


Other Articles:

How to Create a file in Ubuntu Linux using command & GUI
Install Opera Browser on Ubuntu 22.04 LTS…
List Open or closed Ports in UFW Firewall on Ubuntu
How to install WPS Office on Ubuntu 22.04…


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.