Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

OK - I am linux newbie - I am trying to edit a file from bash via edit <filename> command in whatever the default mode is (I am assuming 'vi'?).

Problem is for the hell of me I cannot how to save and out of edit mode - this cheatsheet seems to suggest ESC should do the trick but it doesn't seem to work.

I am connecting via ssh from a mac to a linux suse enterprise 11 box.

Any help appreciated!

share|improve this question
Additionally I would setup some aliases in your .bashrc if you plan to continue using edit so you can specify which editor is used when using the edit command. Personally I just type in vim preceeding a file that I want to edit but to each their own. – Wilshire Jun 19 '11 at 18:45
cheers - thanks for the suggestions! – JohnIdol Jun 19 '11 at 19:59
up vote 6 down vote accepted

Esc will only throw you back into command mode in VI or Vim. To Save and quit press Shift + Z + Z, :wq, or :x in command mode. If you are opening the file in read only mode you will have to hit :q!.

Consider looking at this cheatsheet as well for more macros VI cheatsheet

share|improve this answer
+1 dude - THANKS! – JohnIdol Jun 19 '11 at 18:35
:wq to quit and save. – petrus Jun 19 '11 at 20:13
:x does the same as :wq - but you save one key :) – faker Jun 19 '11 at 22:43
shift + Z worked for me :) – James111 Dec 12 '15 at 0:48

If you are new to Linux I would suggest using something other than vi. For instance, nano is fairly user-friendly, although much less powerful. Also, vim is a variant of vi that has some more features (like syntax highlighting) and is slightly easier to use.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.