Digital Marketing

How To Save A File In Vim / Vi With sudo

To save a file, simply type the following command:
:w !sudo tee %

:w – Write a file (actually buffer).
!sudo – Call shell with sudo command.
tee – The output of write (vim :w) command redirected using tee.
% – The % is current file name. 


Popular posts from this blog