Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I can't save changes after editing

sudo vi /etc/network/interfaces

Text before editing:

auto lo
iface lo inet ...

Edited to:

auto eth0
iface eth0 inet dhcp

What key combination or sequence must I press to save this?

share|improve this question
5  
If you are not comfortable with editing files in terminal based editors like vi or vim, I would recommend using graphical based editor like gedit to open them. Replace sudo vi with gksu gedit. –  Aditya Feb 8 '13 at 15:15
1  
Or use sudo nano Its also command line but a lot more intuitive than vi. –  Warren Hill Oct 19 '13 at 9:46

3 Answers 3

up vote 16 down vote accepted

You're probably in editing/insert mode. You need to type the following sequence :

  1. Esc, to quit edit mode and fallback to command mode ;
  2. :wq, start with a colon and then press w and q to write and quit ;
  3. then press Enter to valid.
share|improve this answer
    
thank you man ..... Useful and what i needed –  And Feb 9 '13 at 9:57

I usually press ESC and then hold Shift and press z twice. Just like you would like to type two capital Z letters in word editor :) That saves your document and closes your editor.

share|improve this answer
    
Oh man, shift and double z, what was the design logic behind that I wonder, "what's the least intuitive command we can create?", ubuntu sometimes pisses me off like mad –  Sam May 25 at 11:10

Check whether you have administrative (root) privileges to edit the file. use this command

whoami

If the result is not "root", then you are not supposed to edit the file.

To login as root user, use the below command

sudo su

or

su

Edit the file,

vi /etc/network/interfeces

After the changes, save the file using

  1. Press Esc to change the mode
  2. :x to save and quit the file

Thats all

share|improve this answer

Your Answer

 
discard

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.