/etc/hosts and Snow Leopard

Discussion in 'macOS' started by mcs37, Dec 12, 2009.

  1. mcs37 macrumors regular

    mcs37

    Joined:
    Mar 2, 2003
    Location:
    Washington, DC
    #1
    Back on Leopard I used /etc/hosts happily like any other *nix box in the last decade, but now on Snow Leopard when I modify it to push a few changes to existing machines, the updated entries don't seem to stick. It seems when I reboot they restore to their old settings so now I have to modify /etc/hosts every time I reboot.

    I'm sure I'm doing something wrong, I just have no idea what that would be -- someone please advise.
     
  2. jbuk macrumors regular

    Joined:
    Jun 8, 2009
    #2
    I'm going out on a whim here, but try giving your account full control of /etc/hosts and the system read-only privileges?
     
  3. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #3
    I haven't had any issues like that. I modified mine to point to my virtual hosts web sites. How are you editing the file? I generally just sudo the file into pico and edit it in Terminal.
     
  4. mcs37 thread starter macrumors regular

    mcs37

    Joined:
    Mar 2, 2003
    Location:
    Washington, DC
    #4
    I just do sudo emacs /etc/hosts -- editing the file like always.
     
  5. mcs37 thread starter macrumors regular

    mcs37

    Joined:
    Mar 2, 2003
    Location:
    Washington, DC
    #5
    Here we are a few weeks later and this problem is still here on Snow Leopard. Every time I reboot the damn machine I have to modify /etc/hosts again to set the local network fixed IPs. I'm a little curious why I'm the only person with this...
     
  6. Azrel macrumors regular

    Azrel

    Joined:
    Jun 8, 2005
    #6
    Are you sure you're writing to the file correctly? I've not used emacs, but here's my routine:

    $sudo nano -w /etc/hosts
    $dscacheutil -flushcache
     
  7. Mumford macrumors regular

    Joined:
    Oct 8, 2006
    Location:
    Altadena, CA
    #7
    Just tested on mine... edited /etc/hosts, then rebooted. My changes persisted.
     
  8. torana355 macrumors 68020

    Joined:
    Dec 8, 2009
    Location:
    Sydney, Australia
    #8
    Mines works fine in SL and worked fine in leopard too. I copy the file to the desktop, open the file in a text editor do my changes then save it. Then i copy it into the etc folder.
     
  9. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #9
    Just a troubleshooting idea: Make the edit as usual, and make note of the modified time for the file from Finder (or Terminal). Then go and reboot and check the modified time to see if it was modified during the reboot at some point.

    As a lame temp solution, you can store a correct hosts file and have it copied into place at login by having the action stored as a launch item. I did this for a Leopard bug for a similar problem.
     
  10. rrpalma macrumors member

    Joined:
    Sep 21, 2008
    #10
    Try editing /private/etc/hosts instead of /etc/hosts
     
  11. galan05 macrumors newbie

    Joined:
    Mar 19, 2010
    #11
    Need help with this, also

    I've never worked one second in Linux, but I have to edit my hosts file in Snow Leopard to point my blog to a new IP address. I can't even FIND the hosts file in Snow Leopard. This is the total directions I was given by the techs at GoDaddy:

    "Host files are text documents that you can edit with any text editor. Add the Server IP Address and your domain name to your host file on an individual line. Follow the format of any previous entries for the order of the IP address and domain name.


    Host file paths for popular operating systems:



    Linux: /etc/hosts

    Macintosh OS X: /etc/hosts"

    If you're familiar with Linux, that may be all you need. I'm not, so I'm totally lost. Can anyone help?

    .greg
     
  12. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #12
    @galan05, the hosts file is in a hidden folder by default, which is likely why you are having problems finding it. Grab TextWrangler, and it will give you an option under the File menu to open hidden files, then you can go to the etc folder at the root level and find the hosts file inside it. Just be careful with the file, you can mess things ups editing it incorrectly. You'll need admin privileges to edit this file as well.
     
  13. joecool99 Suspended

    joecool99

    Joined:
    Aug 20, 2008
    Location:
    USA
    #13
    Experiencing the same problem. Both /etc/hosts and /private/etc/hosts gets replaced during the boot to original state.
     

Share This Page