How to save changes to a file opened in the terminal?

  • Press Ctrl+X or F2 to Exit. You will then be asked if you want to save.
  • Press Ctrl+O or F3 and Ctrl+X or F2 for Save and Exit

The notation for short-cuts is as follows: Control-key sequences are notated with a caret (^) symbol and can be entered either by using the Control (Ctrl) key or pressing the Escape (Esc) key twice. Escape-key sequences are notated with the Meta (M-) symbol and can be entered using either the Esc, Alt, or Meta key depending on your keyboard setup. Also, pressing Esc twice and then typing a three-digit decimal number from 000 to 255 will enter the character with the corresponding value.


Try Ctrl+G in nano to open the built-in help.

enter image description here


^ is a common abbreviation for Ctrl. The editor you're using is nano, and you can find more documentation about it here: http://www.nano-editor.org/dist/v2.2/nano.html#Editor-Basics.

That said, if you have another editor you prefer (e.g. the graphical Gedit editor, or vim), just indicate that using the EDITOR environment variable:

EDITOR=gedit sudoedit /etc/passwd

You could make this "permanent" by exporting EDITOR with the desired value in your ~/.bashrc file.