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:

Copy
:w !sudo tee %

/hat tip to @nistude Archive

Owner of this card:

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