Setting or Resetting Hostname in OSX

There are 3 ways to do this. Some of which are for local service names within OSX. I suggest keeping them all in sync.

Edit the /etc/hostconfig file and change
HOSTNAME=-AUTOMATIC-
to
HOSTNAME=servername.example.com
sudo scutil --set HostName servername
sudo scutil –-set LocalHostName servername
systemsetup -setcomputername servername