Write With Sudo
- One minute read - 85 words - Page SourceA snippet that I find myself needing more often than I’d like to admit - when you’ve opened a file for editing in vim
, but when you go to save you are reminded that it needs root permissions to do so.
:w !sudo tee %
This translates to:
:w
- “write this file1 to…”!
_ “…the stdin of the following command:”tee %
- “the commandtee
, passed as argument <the filename currently being edited>”
-
Technically I think “this buffer” might be more accurate? ↩︎