blogcontent/blog/content/posts/write-with-sudo.md
Jack Jackson 59508b7d59
All checks were successful
Mirror to GitHub / build-and-push (push) Successful in 53s
Gitea Actions Demo / build-and-push (push) Successful in 2m31s
Gitea Actions Demo / update-deployment-repo (push) Successful in 11s
Entry: Write with sudo
2025-04-18 22:06:49 -07:00

605 B

title date tags
Write With Sudo 2025-04-18T22:06:20-07:00
Tech-Snippets

A snippet that I find myself needing more often than I'd like to admit - when you've opened a file for editing in vim, but when you go to save you are reminded that it needs root permissions to do so.

:w !sudo tee %

This translates to:

  • :w - "write this file1 to..."
  • ! _ "...the stdin of the following command:"
  • tee % - "the command tee, passed as argument <the filename currently being edited>"

  1. Technically I think "this buffer" might be more accurate? ↩︎