Where are the host files located in Mac OS X Lion

Discussion in 'Mac OS X Lion (10.7)' started by okizen, Mar 27, 2012.

  1. okizen macrumors member

    Joined:
    Jan 21, 2012
    #1
    In windows 7 they are in /windows/system32/drivers/etc/ but where are the host files in Mac Lion OS X located?
     
  2. SandboxGeneral Moderator

    SandboxGeneral

    Staff Member

    Joined:
    Sep 8, 2010
    Location:
    Orbiting a G-type Main Sequence Star
    #2
    Step 1 – Open the Terminal.app

    Either by start typing Terminal on the Spotlight, or by going into Applications -> Utilities -> Terminal.

    Step 2 – Open the hosts file

    Open the hosts by typing on the Terminal that you have just opened:

    Code:
    $ sudo nano /private/etc/hosts
    Type your user password when prompted.

    Step 3 – Edit the hosts file


    Step 4 – Save the hosts file

    When done editing the hosts file, press control-o to save the file.
    Press enter on the filename prompt, and control-x to exit the editor.
     
  3. okizen thread starter macrumors member

    Joined:
    Jan 21, 2012
    #3
    Thanx SandboxGeneral. But it keeps asking me for a password even though I haven't setup one up and after 3 attempts it logs me off again. Is there a way around this?
     
  4. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #4
    You should have an admin password that you use to log into your Mac or install apps. You should have set it when you first set up your Mac.
     
  5. okizen thread starter macrumors member

    Joined:
    Jan 21, 2012
    #5
    Thanx GGJstudios. I've now set up my admin password and all is working (so far).
     
  6. bravo14 macrumors newbie

    Joined:
    May 27, 2013
    #6
    Hi

    Sorry for jumping onto this post.

    I have followed the instructione above, but the Terminal is not loading the Hosts file, I am not being asked for a password.
     
  7. benwiggy macrumors 68020

    Joined:
    Jun 15, 2012
    #7
    Without seeing the exact commands you typed and the exact response from the system, it's hard to know what is going on.

    If you are unfamiliar with the Terminal environment, I would recommend using TextWrangler, a free text editor app, which can open hidden system files and handle the permissions easily.

    TW will let you browse hidden files and folders in the Open file dialog, and then ask for authorisation if required. It will also save the file with changes made, leaving the the file with the correct attributes.

    It's on the Mac App Store, and can also be downloaded from the Bare Bones website. I consider it (or its paid big brother, BBEdit) essential for any Mac user.
     
  8. wblp macrumors newbie

    Joined:
    May 7, 2013
    #8
    i can't open hosts file with text wrangler application.

    i can see the hidden files, but fail to open it.
    Thank you for help.
     
  9. benwiggy macrumors 68020

    Joined:
    Jun 15, 2012
    #9
    I think there's an option in the Open dialog for whether to enable every type of file, or just allow "text" (.txt) files to be opened.
     
  10. wblp macrumors newbie

    Joined:
    May 7, 2013
  11. desertman macrumors 6502a

    Joined:
    Jul 14, 2008
    Location:
    Arizona, USA
    #11
  12. printz macrumors regular

    Joined:
    Dec 23, 2012
    #12
    Is it required use a terminal-based editor such as nano, vim or emacs? Can you edit root:wheel-owned files with a GUI editor? If you attempt to save, does it ask you for the sudo password, or does it fail?
     
  13. benwiggy macrumors 68020

    Joined:
    Jun 15, 2012
    #13
    See my post above about using TextWrangler.
     

Share This Page