Skip to content

Instantly share code, notes, and snippets.

@tmcolby
Created May 30, 2019 15:13
Show Gist options
  • Save tmcolby/08efd9254ec469634ff572efa7419eb3 to your computer and use it in GitHub Desktop.
Save tmcolby/08efd9254ec469634ff572efa7419eb3 to your computer and use it in GitHub Desktop.

Elevate to root privilage, in VIM, on the go

Suppose you opened a file in the Vim editor, made a lot of changes, and then when you tried saving those changes, you got an error that made you realize that it's a root-owned file, meaning you need to have sudo privileges to save these changes.

:w !sudo tee %

The aforementioned command will ask you for root password, and then let you save the changes.

Credit: https://www.howtoforge.com/linux-tee-command/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment