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?
regards
Fred
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
MacUser2525:~$ ls -l /etc/hosts
-rw-r--r-- 1 root wheel 236B 19 Jan 2013 /etc/hosts
sudo nano /etc/hosts
sudo chown root:wheel /etc/hosts
sudo chmod 0644 /etc/hosts
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
sudo nano /etc/hosts
Restore it from your backup, which you have because you would have made one before attempting to modify any system files.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?
What should I do? I've tried entering pressing cmd + x but nothing seems to happen... :-(
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.
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.
Now I only need to figure out the permission thing.
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.
-bash: MacUser2525:~$: command not found
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!
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.
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
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
#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