I’ve been using Emacs for over two decades and am still surprised by what it can do. While trying to figure out how to edit remote files over sftp I came across documentation for editing files as root using “sudo”.
This feature is part of TRAMP-mode which stands for “Transparent Remote (file) Access, Multiple Protocol” and has been part of Emacs for a very long time. The syntax is very simple – open a file with the prefix /sudo:: and TRAMP will use sudo to fork off a shell
For example, editing a file named:
will allow you to read, edit and write out the /etc/fstab file from the comfort of your Emacs window and without having to switch to a terminal, run sudo, and start up an editor.