Mountain Lion Hosts File

Joined
Feb 26, 2008
Messages
542
Reaction score
25
Points
28
Hi All,

First, please know I'm well aware of how to edit the Hosts file using Terminal... But what I really want to do is edit it using Smultron 4 (which I'd done in the past with Lion and Snow Leopard). That said, I just can't seem to defeat Apple's security in Mountain Lion... Now, setting aside the security implications -- and I know some of you have strong feelings about users being "rightly" disallowed dominion over their own computers -- do any of you have advice on how I can accomplish my desired goal of editing my Hosts file using any text-editing application I want?

Things I've tried already:
  • Changing permissions on the Hosts file using the Get Info window to give myself read/write privileges
  • Taking ownership of the file
  • AppleScript (do shell script "open /Applications/Smultron\\ 4.app/ /etc/hosts" with administrator privileges)
  • Changing permissions for the entire ETC folder (which works - but is somewhat less than ideal given that it leaves everything else exposed that doesn't need to be)

Thanks in advance!

Z
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
First off, don't take any route that involves changing permissions. There's a difference between having control over the filesystem and deferring to the Unix system of permission management. ;)

Try the following:
Code:
sudo /Applications/Smultron\ 4.app/Contents/MacOS/Smultron /etc/hosts
 
OP
Shikarnov
Joined
Feb 26, 2008
Messages
542
Reaction score
25
Points
28
That did the trick. Thank you!

For anybody else that edits the host file frequently, Using Vansmith's detail, I created an AppleScript with the following code, so I can keep an icon on my dock next to MAMP.

Code:
do shell script "sudo /Applications/Smultron\\ 4.app/Contents/MacOS/Smultron\\ 4 /etc/hosts" password "mypassword" with administrator privileges
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
No problem, glad I could help.

One piece of advice (for anyone out there) - make a backup of a working hosts file before you do this, especially if the hosts file is new to you.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top