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. 

Comments

Popular posts from this blog

Fixed WSL sshd: no hostkeys available -- exiting

PowerMTA pmta command

How to fix: mv: failed to preserve ownership