← coderrocketfuel.com

Close/Exit the Nano Editor on Ubuntu

How do you close/exit the nano editor on Ubuntu?

Use this keyboard shortcut:

CTRL + x

If you've made unsaved changes to your file, you'll be asked if you want to save the changes.

Nano Editor Save Changes Prompt

These are your options:

  1. Save your changes by pressing y (for "yes").
  2. Discard your changes by pressing n (for "no"). This will close nano without saving your changes.
  3. Cancel your request to close nano by pressing CTRL + x. This removes the prompt without closing nano or saving/discarding your changes.

If you saved your changes, you'll also be prompted for a file name to write to. This tells nano where to save your changes.

Nano Editor Write File Prompt

Press ENTER to write the changes to the already existing file you were making updates to and close/exit nano.

Thanks for reading and happy coding!