Skip to content

Instantly share code, notes, and snippets.

@danibram
Last active September 23, 2015 07:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danibram/ef6b0a3753906c6190d4 to your computer and use it in GitHub Desktop.
Save danibram/ef6b0a3753906c6190d4 to your computer and use it in GitHub Desktop.
Fix hosts file from corruption
#!/bin/sh
# Solution found here (run with sudo):
# http://superuser.com/questions/866086/localhost-aliases-in-mac-os-x-mysteriously-stopped-working
tr '\015' '\012' < /etc/hosts > /tmp/hosts.$$
mv /etc/hosts /etc/hosts.bad
mv /tmp/hosts.$$ /etc/hosts
chown root:wheel /etc/hosts
chmod 644 /etc/hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment