How to Save and Exit Nano? [Nano Save and Exit]

How to Save and Exit Nano Editor? [Nano Save and Exit] This tutorial guides beginners who want to use save and exit commands in the nano editor.

Updated: 17 Dec, 23 by Antoniy Yushkevych 4 Min

List of content you will read in this article:

Nano is the most fundamental, command-line-based text editor for Linux. It has all common text editor features, including highlighting syntaxes, multiple buffers, scanning, and replacement with regular expression (regex) support, type corrections, and UTF-8 (Unicode Transformation Format – 8-bit) encoding. You can easily save and exit in the nano editor through the command-line options given in this tutorial. This article explains the Nano save command and Nano exit command.

Before continuing, Explore our comprehensive guide on the best text editors available! and Get started with Nano Text Editor: Follow our step-by-step guide!

Save Nano Command: Ctrl+O will save the modifications you've made to the file. You can verify saving with the enter button or cancel it by CTRL + C.

save nano

When you save the file, it will be generated if it does not exist.

Exit Nano Command: Ctrl+X will close nano. If any patches haven't been saved yet into your system, you'll be prompted to do so. You can type yes to save, type no for not to save, or CTRL + C to cancel the exit operation.

exit nano

You must have the write permissions on the file to save it. You must have written permission to the directory where the file would be generated while making a new file in the nano editor to save the file.

Linux  Virtual Server
Linux Virtual Server

Starting From $5.99/Monthly

Assuming you have already written something in the Nano text editor and want to save it before exiting, here are the steps you need to take.

Next, press Ctrl+X on your keyboard to exit the Nano text editor. You will be prompted to confirm that you want to save changes before exiting; simply press Y on your keyboard and then Enter to confirm to save and exit Nano.

To exit the nano text editor without saving your changes, press Ctrl+X. You will be prompted to confirm that you want to exit; press n for no to discard changes will be discarded.

Some Useful Nano Editor Commands

Any command prefixed with a caret symbol (^) means to use the Ctrl key (e.g., ^G means to press the Ctrl+G keys at the same time).

Here we have listed the top nano editor commands that you should know:

  • ^G: nano help
  • ^A: move to the beginning of the line in the nano
  • ^E: move to the end of the line in the nano. Learn advanced Nano commands for shifting the end of the line effortlessly.
  • ^Y: move down a page - next page in nano
  • ^V: move up a page - previous page in nano
  • ^_: move to a specific line (^_^V moves to the top of the file, ^_^Y to the bottom)
  • ^C: find out what line the cursor is currently on
  • ^W: search or find some text in nano. Mastering Nano Editor's Search Functionality: Learn How!
  • ^D: delete the character currently under the cursor. Discover How to Delete Lines in Nano Editor like a Pro
  • ^K: delete the line in nano, nano remove the line
  • Also, to remove, clear, or delete some content or multiple lines, you can select lines with your mouse and then use CTRL+K.
  • ^O: save file nano (you will be prompted for a file to save to)
  • ^X: exit nano (you will be prompted to save your file if you have not)

Using the commands Ctrl+O and Ctrl+X, you can easily save the Nano file or exit the Nano editor. But be careful; you must have written permission to do these for all the files and directories you are working on, and then only you can make any changes in the nano editor. Hence in this way, we can save and exit in the nano editor using the command line.

Antoniy Yushkevych

Antoniy Yushkevych

Master of word when it comes to technology, internet and privacy. I'm also your usual guy that always aims for the best result and takes a skateboard to work. If you need me, you will find me at the office's Counter-Strike championships on Fridays or at a.yushkevych@monovm.com