10 Replies Latest reply: Mar 20, 2010 7:37 PM by i.3d
galan05 Level 1 (0 points)
I have a blog on GoDaddy that is being switched from Windows hosting to Linux hosting. The Lionux version has a temporary domain name. I need to edit the hosts file to point the IP address of the Linux-hosted blog to the old domain name, then kill out the Window-hosted IP address. I'm told this is a relatively simple process once I access the hosts file.

I've never worked in Linux. I don't know where/how to find the hosts file. And the instructions I've found online that applied to Leopard don't seem to apply to Snow Leopard.

Where/how can I find this hosts file so I can point the IP address to its correct domain name?

iMac, Mac OS X (10.6.2)
  • musicwind95 Level 4 (1,280 points)
    First, download TextWrangler (free).

    Open a Finder window. In the Go menu, select +Go to Folder+. Type in /etc and click Go. Find the file called hosts (it won't have a file extension). Open the file with TextWrangler. Do the editing. When you click Save, it will prompt you for an administrator password in order to save. Do so, and it will save.
  • galan05 Level 1 (0 points)
    I don't have TextWrangler. i have TextEdit. Will that suffice?
  • galan05 Level 1 (0 points)
    I'm doing something wrong. When I try to save it, I get an error msg saying "the document 'hosts' could not be saved."

    Also, there's some coding on that file for "localhost" which is says I should not change. Am I on the wrong file?
  • thomas_r. Level 7 (30,749 points)
    That's probably because you tried to do it with TextEdit. You were pointed to TextWrangler for a reason... it will authenticate to allow you to edit that file, which you normally do not have write access to.
  • musicwind95 Level 4 (1,280 points)
    galan05 wrote:
    I'm doing something wrong. When I try to save it, I get an error msg saying "the document 'hosts' could not be saved."


    As Tom said, TextEdit will not suffice; TextWrangler will give you temporary access to change this file which you normally don't have permissions to modify. It was made hard-to-find for a reason.

    Also, there's some coding on that file for "localhost" which is says I should not change. Am I on the wrong file?


    No. You're exactly on the right file you should be on. Just don't change that first line, which says something like

    +127.0.0.1 localhost+

    and you'll be perfectly safe.

    Message was edited by: musicwind95
  • galan05 Level 1 (0 points)
    Okay...TextWrangler it is. Didn't have it, had to download it. Trying again.

    Message was edited by: galan05
  • galan05 Level 1 (0 points)
    Once I knew where to find the needed file, it was just a matter of downloading TextWrangler and using that to edit the hosts file. That did the trick.

    Thanks for all your help!
  • i.3d Level 2 (415 points)
    You can edit hosts using text edit if you set the prefs (in text edit) to save plain text file and no extension.
    To actually save the file you MUST change access rights to the etc folder - CMD+i and add read and write for your account.
    Later run repair permissions and it will be just fine and dandy.
  • musicwind95 Level 4 (1,280 points)
    Wouldn't it be easier to use TextWrangler than to modify permissions of a hidden system folder? TextWrangler has other uses too.
  • i.3d Level 2 (415 points)
    Probably. I just wanted to point out that one COULD use TE as well.