MacOS – How to edit the /etc/hosts file

hostsmacosterminaltextedit

When I open the file with TextEdit (I don't want (truly, I am not able) to use vim), it is seen as "locked", even if I modify the permissions of the file via the "Get Info" window.

How can I modify the hosts file with TextEdit?

Best Answer

In one line, from Terminal:

sudo -b "/Applications/Textedit.app/Contents/MacOS/TextEdit" /etc/hosts

Make your changes, save and close.