TrickAndTweak

Linux Tricks Save A File When Opened As Read-only

:w !sudo tee %

  • :w = Write a file.
  • !sudo = Call shell sudo command.
  • tee = The output of the vi/vim write command is redirected using tee.
  • % = Triggers the use of the current filename.
  • Simply put, the ‘tee’ command is run as sudo and follows the vi/vim command on the current filename given.

Trick and tweaks

Other

Certification materials

edit SideBar

Blix theme adapted by David Gilbert, powered by PmWiki