Despite being one of the easier to use text editors, it can still be confusing the first time you open it, especially if you're used to GUI applications. In this guide, we'll go over the step by step instructions to save and exit a file in nano. This is one of the most common and recurring tasks you'll ever do with the text editor.In this tutorial you will learn:
- How to save and exit a file in nano editor
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the |
|Conventions|| # - requires given linux commands to be executed with root privileges either directly as a root user or by use of |
Save and exit a file using nano editor
We're assuming you've already opened a file with the usual syntax:
$ nano file-name
After you've made some changes to the file and you wish to save them, use the following instructions to save the file and exit nano.
- To exit and save the file, start by pressing
Ctrl + Xon your keyboard. This will attempt to exit nano. To remember this keyboard combination, check the bottom of the nano menu.
Ctrl + X.
- You'll now be asked if you want to save your changes to the file. You need to respond by entering either "Y" or "N". Since we are trying to save our changes, press "Y" and hit enter.
- Next, you'll be asked to give a name to the file. If you're trying to overwrite an existing file with your current changes, then you can simply hit enter on your keyboard. Otherwise, fill out a new file name.
That's all there is to it. As long as you had write permissions on the file you were editing, your new changes will be applied to the file.
In this guide, we saw how to exit and save a file using the nano editor on Linux. The key to remember is that you need to press
Ctrl + X to close the editor. For everything else, you can simply follow the prompts or refer back to our guide.