I spend much time in vi/vim. As a good little Sysadmin, I seldom wander around file-systems as root. Of course, I often forget sudo before spending much time editing system files in vi. This leads me to seeing our friendly error message in the post’s title.
In comes this command:
:w !sudo tee %
I’ve probably typed this enough times, that I’ll never forget it. That being said, having it lying around here will ensure that.
Here’s a great explanation of what the heck it’s doing: