The Perils of `sudo vim`

Introduction On a UNIX-like system, one often has the need to edit a write-restricted file and thus to escalate one&rsquo;s privileges to do so; the obvious approach that might initially occur to you is to use sudo vim or sudo $EDITOR to edit the file with superuser privileges, but this is inadvisable for a number of reasons, the majority of which boil down to the principle of least privilege :…