PDA

View Full Version : Hosts file?




ifred1
Sep 2, 2013, 01:44 AM
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



MacUser2525
Sep 2, 2013, 02:04 AM
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

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


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.


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.


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.


sudo chown root:wheel /etc/hosts
sudo chmod 0644 /etc/hosts

ifred1
Sep 2, 2013, 03:16 AM
Your /etc/hosts file? If so the contents should be this.


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.


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.


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.


sudo chown root:wheel /etc/hosts
sudo chmod 0644 /etc/hosts


Hi Man

Thanks for the quick respons! I can't seem to save the content on the screen that pops up after typing

sudo nano /etc/hosts


What should I do? I've tried entering pressing cmd + x but nothing seems to happen... :-(

benwiggy
Sep 2, 2013, 06:51 AM
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?
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.

tag
Sep 2, 2013, 07:32 AM
What should I do? I've tried entering pressing cmd + x but nothing seems to happen... :-(

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.

ifred1
Sep 2, 2013, 12:56 PM
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.

I Confess, my timemashine was out of order... :rolleyes:

ifred1
Sep 2, 2013, 01:07 PM
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.

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:

MacUser2525
Sep 2, 2013, 01:18 PM
Now I only need to figure out the permission thing. :rolleyes:

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.

ifred1
Sep 2, 2013, 01:39 PM
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.

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

-bash: MacUser2525:~$: command not found

Thanks again for helping me out!

MacUser2525
Sep 2, 2013, 01:52 PM
If I type in the first command just aften opening terminal I get the error:

-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.

ifred1
Sep 2, 2013, 02:28 PM
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.

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

Another quistion you worte the code with:

MacUser2525:~$ cat /etc/hosts

on to it should only be like this right?:

##
# 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
Sep 2, 2013, 02:39 PM
Okay did it with just the commands you wrote, and it seemend to work.

Another quistion you worte the code with:

MacUser2525:~$ cat /etc/hosts

on to it should only be like this right?:

##
# 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 :-)

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.



#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

ifred1
Sep 2, 2013, 02:59 PM
Thanks man!