How do I save changes after editing vi /etc/hosts?

90,759

Solution 1

First press ESC so you get back to command mode, then do.

:x (quit and save)

or

:w
and
:q

or

:wq

Solution 2

You can also use the shortcut Shift-Z-Z from command mode (as Anders said, press Esc to exit Insert mode and return to Command mode) to save and exit to the command prompt.

Share:
90,759

Related videos on Youtube

Gaff
Author by

Gaff

Updated on September 17, 2022

Comments

  • Gaff
    Gaff over 1 year

    I am doing a Linux installation. I installed the system fine and am trying to change the vi /etc/hosts file. I have edited the file but am not sure how to save it.

    I have --INSERT-- showing at the bottom.

  • igorlord
    igorlord almost 14 years
    I believe you can also do :wq to save and quit in one command.
  • SilverViper
    SilverViper almost 14 years
    @Grant Palin, That is correct.