Posts Tagged 'sudo'

Save File With Sudo Permissions In VIM

A lot of time I open a file, make changes and when the time comes to save it realize that I hadn’t sudo’ed it. Learnt that the following command helps:

:w ! sudo tee %

Here’s the reason:

:w tells the vi to save modification of the file

! sudo tee executes the tee command with sudo permissions taking it’s input from :w

% here ...

Continue Reading ?
0