LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-17-2008, 10:36 PM   #1
donlobeto
LQ Newbie
 
Registered: Apr 2008
Posts: 4

Rep: Reputation: 0
Unhappy 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.
 
Old 04-17-2008, 11:05 PM   #2
frndrfoe
Member
 
Registered: Jan 2008
Distribution: RHEL, CentOS, Ubuntu
Posts: 379

Rep: Reputation: 38
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.

Last edited by frndrfoe; 04-17-2008 at 11:06 PM.
 
Old 04-18-2008, 01:44 AM   #3
LinuxManMikeC
Member
 
Registered: Nov 2007
Location: Provo, Utah
Distribution: Debian and Ubuntu
Posts: 74

Rep: Reputation: 15
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.
 
Old 04-18-2008, 01:48 AM   #4
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
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.
 
Old 04-18-2008, 06:02 AM   #5
marquardl
Member
 
Registered: Apr 2008
Posts: 100

Rep: Reputation: 15
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

Last edited by marquardl; 05-01-2008 at 04:52 AM.
 
Old 04-18-2008, 10:45 AM   #6
frndrfoe
Member
 
Registered: Jan 2008
Distribution: RHEL, CentOS, Ubuntu
Posts: 379

Rep: Reputation: 38
mis spoke... ignore

Last edited by frndrfoe; 04-18-2008 at 10:46 AM.
 
  


Reply

Tags
file recovery


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create a new file including content from reading another file !? silverhand Programming 2 10-06-2007 05:33 PM
Show file Content on File Select HTML stranger_6_7 Linux - General 4 09-25-2007 12:52 AM
gave wrong syntax for tar as tar -cvzf file file.tgz how to recover the file gautham Linux - General 4 04-13-2005 04:15 AM
does the /etc/hosts file work same as the M$ hosts file? Lleb_KCir Linux - Software 6 04-03-2004 05:33 PM
How do I recover the content of /etc/modules.conf? billhull Red Hat 2 12-17-2003 08:39 AM


All times are GMT -5. The time now is 04:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration