LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Is there a way to recover the content of /etc/hosts file? (https://www.linuxquestions.org/questions/linux-newbie-8/is-there-a-way-to-recover-the-content-of-etc-hosts-file-636129/)

donlobeto 04-17-2008 09:36 PM

Is there a way to recover the content of /etc/hosts file?
 
I am new to linux (unix in general) and while exercising "tr" command from
one of my school books, I end up erasing the content of the /etc/hosts file and then I read the following note:
#Do not erase the following line, or various programs
# that require network functionality will fail.

I use cat command to see which line my book was referring to and found that
the file is empty.

So, my question is how to fix this problem. Is there a way to know to recover the content of that file? How.

I'm using a Mac OS X (10.5 ) Leopard on the Intel iMac.

frndrfoe 04-17-2008 10:05 PM

Stick this in there and the "various programs" should be ok.

Code:

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1      localhost.localdomain  localhost

You may also need to add a line for the ip address and hostname that your machine uses if you are running network servers.

LinuxManMikeC 04-18-2008 12:44 AM

I don't know how things are in Mac, but that file shouldn't be accessible by regular users, only the administrator account (root). Don't play around learning stuff as root, you might break something.

jay73 04-18-2008 12:48 AM

Quote:

127.0.0.1 localhost
127.0.1.1 Selena

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
The second line is only required if your computer has a name; if it has, don't forget to substitute Selena with the actual one.

marquardl 04-18-2008 05:02 AM

empty vhosts
 
If you don't run a public web server or any other server services to the outside world, then an empty /etc/vhosts file will do not much harm. You will not be able to access your local Apache web server as localhost, if you have one , but that's probably all.

You have been lucky that only /etc/hosts got destroyed. Be careful.

Bye,
M

GWN

frndrfoe 04-18-2008 09:45 AM

mis spoke... ignore


All times are GMT -5. The time now is 02:05 AM.