Posted about 11 years ago. Visible to the public.

Save file in vi using sudo

If you edit a file with vi as normal user, but need superuser rights to save it, you can use this sequence to save it using sudo:

:w !sudo tee %

/hat tip to @nistude Archive

Owner of this card:

Matthias Marschall
vim, linux
Posted by Matthias Marschall to Matthias Marschall
This website uses short-lived cookies to improve usability.
Accept or learn more