Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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

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 ) – Gilles Quenot Feb 20 '13 at 11:44

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .