+370 5 205 5502 sales@monovm.com

How to Save and Exit in Nano Editor? [A Beginner's Guide]

This tutorial is a guide for all the beginners who want to use save and exit commands in nano editor.

14 Mar, 22 by Antoniy Yushkevych 2 min Read

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 support, type corrections, and UTF-8 encoding. You can easily save and exit in the nano editor through the command-line options given in this tutorial. 

  1. Save Nano Command: Ctrl+O will save the modifications you've made to the file. When you save the file, it will be generated if it does not already exist.
  2. 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 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  VPS
Linux VPS

Starting From $5.99/Monthly

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 command which you should know:

  • ^G: nano help
  • ^A: move to beginning of line in nano
  • ^E: move to end of line in nano
  • ^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
  • ^D: delete character currently under the cursor
  • ^K: delete line in nano, nano remove line
  • Also for remove or 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 command Ctrl+O and Ctrl+X, you can easily save nano file and exit a file in a nano editor. But be careful; you must have the write permission to do these for all the files and directories you are working on, and then only will you be able to make any changes in the nano editor. Hence in this way, we can save and exit in the nano editor using the command line.

People are also reading:

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