Newsletter Subscribe
Enter your email address below and subscribe to our newsletter
So you just made a few changes to a file in the Nano editor but now you can’t figure out how you are supposed to save changes and exit from the Nano editor.
Worry not.
There are a few shortcuts that you can use to save changes and exit from the nano editor:
Ctrl + S
to save the file without a prompt.Ctrl + O
and confirm the filename by pressing the Enter
key to save changes.Ctrl + X
to exit the nano editor and will prompt to save changes if the recent changes are not saved. Yep, it’s that simple.
Want more details, here you have it.
Table of Contents
By far, the easiest way to save changes and continue editing the file is to press Ctrl + S
which won’t prompt for any confirmation and save changes without any additional steps.
For example, here, I created a new file and saved changes by pressing Ctrl + S
:
As you can see, when I pressed Ctrl + S
it wrote 2 lines to the file suggesting the changes have been saved.
Pretty easy, right?
While the previous method was the most efficient way to save changes in the nano editor, you might want to confirm the filename before writing changes.
In that case, you can refer to this method which will prompt you to confirm the filename before you save changes to the file.
To do so, first press the Ctrl + O
shortcut and it will ask you to confirm the filename:
To confirm the filename, press the Enter
key and it will show you how many lines were written to the file. In my case, there were only two lines:
From here, you can either continue editing the file or exit the nano editor (showing how-to in a moment).
Once you save changes from any of the two shown methods, you can exit from the nano editor, you can press Ctrl + X
and it will close the nano editor and bring the terminal prompt.
But what if you forgot to save changes? Worry not, when you press the Ctrl + X
and if the changes are not saved, it will ask whether you want to save changes before quitting the nano editor.
When you forget to save changes and press Ctrl + X
, it will ask you whether you want to save the file or not. You can press Y
if you want and in the next step, it will ask you to confirm the filename. There, you simply press the Enter
key and that’s it:
That’s it!
This was a quick tutorial on how you can save and exit from the nano editor but if you want to learn how to use the nano editor from zero to advanced, then we wrote a detailed guide on that topic:
If you have any other questions, leave us a comment and we will get back to you ASAP 🙂