Results 1 to 5 of 5
  1. #1

    Shikarnov's Avatar
    Member Since
    Feb 26, 2008
    Posts
    542
    Mountain Lion Hosts File
    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

  2. #2

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,740
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    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
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

  3. #3

    Shikarnov's Avatar
    Member Since
    Feb 26, 2008
    Posts
    542
    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

  4. #4

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,740
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    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.
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

  5. #5

    cradom's Avatar
    Member Since
    Feb 14, 2004
    Location
    Groves, Texas
    Posts
    4,402
    Specs:
    13in macbook - 10.11 --- 21in. iMac 10.11 --- HP win 8
    Always listen to experts. They’ll tell you what can’t be done and why. Then do it!
    -Lazarus Long

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. media and file sharing on mountain lion
    By DrDandroid in forum OS X - Operating System
    Replies: 0
    Last Post: 09-16-2013, 02:40 AM
  2. Custom file formats not read by application on Mountain Lion
    By AJAYK in forum OS X - Operating System
    Replies: 4
    Last Post: 04-25-2013, 08:03 AM
  3. File transfer from Mountain Lion to Windows 7
    By kjeand in forum OS X - Operating System
    Replies: 0
    Last Post: 10-02-2012, 05:56 AM
  4. Lost my suders file Mountain Lion
    By shellback3 in forum OS X - Operating System
    Replies: 6
    Last Post: 09-16-2012, 06:48 PM
  5. Tip: Unlocking Hosts file in Lion
    By Shikarnov in forum OS X - Operating System
    Replies: 9
    Last Post: 02-06-2012, 02:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •