Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

On my Mac (running OS 10.6.8), I can edit my hosts file with sudo vi /etc/hosts, but changes I make don't seem to persist through restarts or possibly awaking from sleep mode.

Is there a way to make these changes persist?

Here's a sample change adding an override for

$ cat /etc/hosts
# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##   localhost broadcasthost
::1             localhost 
fe80::1%lo0 localhost

Update: I am also using Cisco AnyConnect VPN software, and that turned out to be the clue. See Daniel's answer below.

Update 2013-05-20: This behavior was fixed/changed by Cisco in AnyConnect v3.0.5080 (or higher), released in Spring 2013. Release Notes - search for

share|improve this question
possible duplicate of /etc/hosts getting reset in Lion – Daniel Beck Jan 26 '12 at 18:18
@user606723 /etc is a symbolic link to /private/etc. – Daniel Beck Jan 26 '12 at 18:18
Brian, are you using Cisco VPN software? Do you have the file /etc/ – Daniel Beck Jan 26 '12 at 19:42
Bingo! I am in face using Cisco AnyConnect VPN. I updated /etc/ file and it now persists the changes. Please put this as an answer and I'll accept it. – BrianC Jan 26 '12 at 19:54
up vote 11 down vote accepted

You are using Cisco AnyConnect software, which will overwrite /private/etc/hosts with /private/etc/ Just edit that file instead.

share|improve this answer

Thanks to @Danial's explanation. Using a wrapper script to edit hosts rather than edit it directly would ease your pain a lot.

sudo vim $ORIG
wait $pid
sudo cp $ORIG $FUCKER
echo "$ORIG copied to $FUCKER"
share|improve this answer

Your Answer


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.