Possible Duplicate:
Becoming root from inside Vim
It could happen to anyone. The admin types:
vi /etc/resolv.conf
as a regular user. He edits the /etc/resolv.conf
file, but when he wants to hit :x
he suddenly notices that he was editing the file in read-only mode because he opened it with a normal user, not root.
Are there any vi commands to get root privileges, so that the admin won't have to hit :q!
and sudo su -
and vi /etc/resolv.conf
and edit it again?
sudo vi /etc/resolve.conf
should be sufficient, no need to start a root login shell. – Mat Jan 04 '12 at 08:17sudo vi ...
. It doesn't quite do what you asked, but it avoid having to re-enter the changes you've made. – Keith Thompson Jan 04 '12 at 09:09