1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Hosts file?

Discussion in 'OS X Mountain Lion (10.8)' started by ifred1, Sep 1, 2013.

  1. macrumors newbie

    #1
    Hi :)

    I've been googleing for some time now, and therefore I try this forum.
    I accedently deleted my hosts file i Mountain Lion (10.8.4), and I want to bring it back. Can somebody help me on how to do so? :confused:

    regards

    Fred
     
  2. macrumors 65816

    #2
    Your /etc/hosts file? If so the contents should be this.

    Code:
    MacUser2525:~$ cat /etc/hosts
    ##
    # Host Database
    #
    # localhost is used to configure the loopback interface
    # when the system is booting.  Do not change this entry.
    ##
    127.0.0.1	localhost
    255.255.255.255	broadcasthost
    ::1             localhost 
    fe80::1%lo0	localhost
    
    The permissions on the file.

    Code:
    MacUser2525:~$ ls -l /etc/hosts
    -rw-r--r--  1 root  wheel   236B 19 Jan  2013 /etc/hosts
    
    To get it back open the Terminal.app and type in then hit enter key.

    Code:
    sudo nano /etc/hosts
    
    Enter your password then copy and paste the contents I posted above into file you have open in Terminal.app. Once pasted hit the Control and X keys answer yes to saving the file. Now for proper ownership and permissions type in then hit enter key the two commands below.

    Code:
    sudo chown root:wheel /etc/hosts
    sudo chmod 0644 /etc/hosts
    
     
  3. macrumors newbie

    #3
    Hi Man

    Thanks for the quick respons! I can't seem to save the content on the screen that pops up after typing
    Code:
    sudo nano /etc/hosts
    
    What should I do? I've tried entering pressing cmd + x but nothing seems to happen... :-(
     

    Attached Files:

  4. macrumors 68020

    #4
    Restore it from your backup, which you have because you would have made one before attempting to modify any system files.

    Otherwise, use TextWrangler to create and save the file, (or to edit it if a new one has been created).

    TW is free and essential for the easy editing of system text files.
     
  5. tag
    macrumors 6502a

    tag

    #5
    The modifier is control, not command. So try control + X. You should then get a prompt asking if you want to save. Hit yes, and it will save then exit you out of nano.

    Alternatively, you can also manually save first before exiting by hitting control + O, and then control + X.
     
  6. macrumors newbie

    #6
    I Confess, my timemashine was out of order... :rolleyes:
     
  7. macrumors newbie

    #7
    Got it back YEEES - Damn YOU GUYS ROCK :cool::cool::cool:!!! Thanks A LOT!!! Been trying to crack this (pardon my french) bitch, but couldn't get it done.

    Now I only need to figure out the permission thing. :rolleyes:
     
  8. macrumors 65816

    #8
    Disk Utility I am thinking could do it with its repair permissions option perhaps or a copy and paste of the two commands listed in my first post into the Terminal.app window will.
     
  9. macrumors newbie

    #9
    If I type in the first command just aften opening terminal I get the error:

    Code:
    -bash: MacUser2525:~$: command not found
    Thanks again for helping me out!
     
  10. macrumors 65816

    #10
    You are putting in the wrong part that is telling you it cannot find the MacUser2525 command, do it with just the commands themself sudo chown root:wheel /etc/hosts and sudo chmod 0644 /etc/hosts.
     
  11. macrumors newbie

    #11
    Okay did it with just the commands you wrote, and it seemend to work.

    Another quistion you worte the code with:

    Code:
    MacUser2525:~$ cat /etc/hosts
    on to it should only be like this right?:

    Code:
    ##
    # Host Database
    #
    # localhost is used to configure the loopback interface
    # when the system is booting.  Do not change this entry.
    ##
    127.0.0.1	localhost
    255.255.255.255	broadcasthost
    ::1             localhost 
    fe80::1%lo0	localhost
    Sorry man I'm really living up to the newbie under my name and the Thread Starter :)
     
  12. macrumors 65816

    #12
    Exactly leave out the first of it where I show the actual command I used to get the output you put in the file. Alternatively the file could look like this and still be correct as the # character has been placed in front of the part not needed making it a comment not to be read and used by the system.


    Code:
    #MacUser2525:~$ cat /etc/hosts
    ##
    # Host Database
    #
    # localhost is used to configure the loopback interface
    # when the system is booting.  Do not change this entry.
    ##
    127.0.0.1	localhost
    255.255.255.255	broadcasthost
    ::1             localhost 
    fe80::1%lo0	localhost
     
  13. macrumors newbie

    #13
    Thanks man!
     

Share This Page