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

How to fix Google Apps Script: Script function not found: doGet

Creating sort index in MySQL

How to fix: df shows no file systems processed on Linux