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

As it required root access to edit, I've opened a init.txt file using sudoedit, but I don't see how to save my changes. I also see lots of things like ^X instructions at the bottom of the terminal which I'm clueless about.

2 Answers

  • 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

0

^ is a common abbreviation for Ctrl. The editor you're using is nano, and you can find more documentation about it here: .

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.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like