How can I quickly edit root owned files like /etc/hosts and /etc/apache2/httpd.conf in a text editor such as TextEdit which would let me do modern text editor operations, without actually running the editor in sudo -b mode first, or without using nano, vim and other terminal based editors?
Ever since Lion came out, doing
$sudo open -e /etc/hosts
no longer works – the file remains locked when TextEdit opens it.
Best Answer
sudo
andopen
provide all the functionality already for editing files of other users so you can just runto edit
/etc/hosts
. Make sure to quit Textedit at the end (Cmd-Q) because otherwisesudo
won't notice that you're done with editing.To make life easier add the following to your
.bashrc
(or.alias
if you have it)