I can't save changes after editing
sudo vi /etc/network/interfacesText before editing:
auto lo
iface lo inet ...Edited to:
auto eth0
iface eth0 inet dhcpWhat key combination or sequence must I press to save this?
24 Answers
You're probably in editing/insert mode. You need to type the following sequence :
- Esc, to quit edit mode and fallback to command mode ;
- :+w+q, start with a
:(colon) then presswand finallyqto write and quit (or just:wto write without quitting) - then press Enter to valid.
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.
6Check whether you have administrative (root) privileges to edit the file. use this command
whoamiIf the result is not "root", then you are not supposed to edit the file.
To login as root user, use the below command
sudo suor
suEdit the file,
vi /etc/network/interfecesAfter the changes, save the file using
- Press
Escto change the mode :xto save and quit the file
Thats all
this question was answered a long time ago, but in case it comes up in search engines again, this link is a nice vim cheatsheet that you might want to bookmark if you use vim a lot.
By the way, You can use :wq to save and exit the file ( you should first press esc key to exit insert or replace mode and then press commands ) and use :q! to exit without saving.