When working with the Linux terminal, it is obvious to use nano text editor for creating, and editing text files or configuration files. Nano is the default text editor that comes with the default installation of Ubuntu 22.04. It provides the basic functionality of editing and creating text files. It has a simple user environment, which is very easy to use.

In this article, we will see, how you can save files and exit the nano editor.

How to Save and Exit Nano Editor?

It becomes very difficult for a new user to save a file when it comes to a command line text editor like Nano. Because there is no save GUI option available in the nano text editor. Let’s follow the instructions given below if you find it difficult to save files and exit the nano text editor.

Launch the Terminal

Press the “Ctrl + Alt + t” keys to launch the terminal. Then write the following command to open the file in the nano text editor:

$ nano file01.py

The command will open the file01.py file in the nano text editor:

Now you can write your desired text/code in this file:

If you want to save the changes, press “Ctrl + OOR Ctrl + s” and hit the “Enter” key, At the bottom of the window you will see the number of lines you have written and saved:

Now if you want to exit from the nano text editor, press “Ctrl + x”, and the nano text editor window will be closed, and you’ll return to the terminal window. 

This is how you can save files and exit from the nano text editor.

Conclusion

To save the files in the nano text editor, press the “Ctrl + s” or “Ctrl + O”, and to exit from the nano text editor, press “Ctrl + x”. In this article, we have explained how you can save and exit the nano text editor. 

Frequently Asked Questions

How do I save a file in Nano text editor using keyboard shortcuts?

To save a file in Nano text editor, press 'Ctrl + O' or 'Ctrl + s' and then hit the 'Enter' key.

What is the default text editor in Ubuntu 22.04 for editing text files?

Nano is the default text editor that comes with the default installation of Ubuntu 22.04 for editing and creating text files.

How can I open a file in Nano text editor through the terminal?

To open a file in Nano text editor through the terminal, launch the terminal and use the command '$ nano filename'.

How do I exit Nano text editor and return to the terminal?

To exit Nano text editor, press 'Ctrl + x', and the Nano window will close, returning you to the terminal.

What key combination is used to launch the terminal in Linux?

To launch the terminal in Linux, press 'Ctrl + Alt + t' keys.

How can a new user save files in Nano text editor without a GUI option?

New users can save files in Nano text editor by pressing 'Ctrl + O' or 'Ctrl + s' to save and 'Ctrl + x' to exit.

What is the basic functionality of the Nano text editor?

Nano text editor provides basic functionality for editing and creating text files with a simple user environment.

What keys are used to show the number of lines in Nano text editor?

To show the number of lines in Nano text editor, press 'Ctrl + c' or 'Ctrl + g'.