Mac OS X – how to update /etc/hosts

Way back in the good old days of Linux and Windows it was much easier to update my hosts file. There it was, /etc/hosts or C:\windows\hosts, edit, save and the change becomes active.

MacOS X is a little more complicated. Once you update /etc/hosts you’ll have to update the Netinfo Database. That’s why I’m blogging this so I’ll remember it. This page documents the steps required but the important command is this one:

sudo niload -v -m hosts . < /etc/hosts

There is a GUI but it’s a little clunky and duplicating an existing entry isn’t the most elegant method of adding a new one. Especially when a warning dialog pops up!

Thanks Barry for suggesting a similar fix while I was in SF and getting used to my new laptop! 🙂