Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using a Linux Ubuntu Precise 12.04 version. I have added a virtual host entry in my /etc/hosts

XX.XX.XX.XX     www.domain-name.com

After sometime, this entry got deleted automatically. What could be the possible reason behind it? How do I prevent it?

share|improve this question
add comment

migrated from stackoverflow.com Feb 20 '13 at 16:40

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 1 down vote accepted

Try doing this :

chattr +i /etc/hosts

even root will not be allowed to remove or modify the file until you run :

chattr -i /etc/hosts

See man chattr

share|improve this answer
    
trying .. lets see after some time, if it works, thanks :) –  Saurabh Saxena Feb 20 '13 at 11:43
    
Try this : cp -a /etc/hosts /etc/hosts_20130220, rm -f /etc/hosts, you will see immediately ;) ( or just try to modify the file ) –  sputnick Feb 20 '13 at 11:44
add comment

The hosts file is automatically generated by default in ubuntu 12.04. The way to stop this from happening is to make /etc/hosts a normal file instead of a symlink.

The easiest way to do this is to copy the file and move it back.

sudo cp /etc/hosts /etc/hosts.new
sudo rm /etc/hosts
sudo mv /etc/hosts.new /etc/hosts
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.