Saturday, April 6, 2013

Save file in vim as root even when you opened it as user

:w !sudo tee %

w ! takes the file content and pipes it into the following shell command
sudo tee (the shell command)  sudo opens tee as superuser and tee writes the input to a given parameter
% (the given parameter) is replaced with the current filename

No comments:

Post a Comment