2010/09/20

Save changes when not editing as root


Thanks to Kate Pauls for this one!

:w !sudo tee %


Sometimes you end up editing a file when not root. Some people are always logged in as root but, if you're a sudoer as I try to be most of the time, sometimes you forget you didn't intend to make changes before opening a root owned file in vi just to view it and end up wanting to make changes.

No comments:

Post a Comment