Why is it that so many Ubuntu guides tell you to do sudo gedit /path/to/somefile when there is a sudoedit command? An editor, like Gedit, doesn’t need to run as root, ever.
This is so much better and safer:
SUDO_EDITOR=gedit sudo -e /path/to/somefile
This will …
- Copy the file to
/tmp/ - Invoke
geditas your user - Update the original file if you changed the temporary file
It would of course be really useful if gksudo had this built in already, and could be used in a nice way by nautilus-gksu.
MMN-o
“This will …
How is this safer? /tmp/ is readable by anyone on the system, even non-administrator users. So, if the file contains a password or something sensitive, anyone can read it…
The main thing is that you aren’t running the editor as root.
/tmpshould have the sticky bit set (chmod +t) meaning files created there can’t be deleted or renamed by anyone other than the owner. So if you create a file there with restrictive permissions (likechmod 600) then it would be perfectly safe.