Nano is a lightweight and user-friendly text editor for Linux and Unix-based systems. Whether you’re editing configuration files or writing scripts, knowing how to save and exit Nano efficiently is essential. This guide covers the steps and shortcuts you need to master Nano.


How to Save and Exit Nano

1. Save Changes and Exit

  1. Press Ctrl + O to save the file.
  2. Press Enter to confirm the filename.
  3. Press Ctrl + X to exit Nano.

Note: If the file is new, you’ll be prompted to enter a filename before saving.


2. Exit Without Saving

  1. Press Ctrl + X.
  2. When prompted to save, press N to discard changes and exit.

3. Save Without Exiting

  1. Press Ctrl + O.
  2. Press Enter to confirm the filename.

Useful Nano Editor Commands

Here are some essential Nano shortcuts to enhance your productivity:

  • Help: Ctrl + G
  • Move to Start of Line: Ctrl + A
  • Move to End of Line: Ctrl + E
  • Next Page: Ctrl + V
  • Previous Page: Ctrl + Y
  • Go to Specific Line: Ctrl + _ (then enter the line number)
  • Show Cursor Position: Ctrl + C
  • Search Text: Ctrl + W
  • Delete Character: Ctrl + D
  • Delete Line: Ctrl + K
  • Save File: Ctrl + O
  • Exit Nano: Ctrl + X

Conclusion

Saving and exiting Nano is simple with the right shortcuts. Use Ctrl + O to save and Ctrl + X to exit. Whether you’re a beginner or an experienced user, these commands will help you work efficiently in Nano.

For more advanced tips, refer to the official Nano documentation.