scutil to the rescue
I have a dual g5 running os x 10.4 and getting
its IP and hostname via DHCP. The machine's
name was supposed to be tarsier, and was by
most accounts. For some reason though, running
hostname at the command line showed the name to
be jtm64791.
I started off by verifying that the computer
name was set to be tarsier in every gui based
config location I could think of. Sharing,
NetInfo, etc. Everything looked good.
I tried:
$grep jtm64791 /etc/*
and found a few locations that had the
bad name; I changed them and rebooted. The name
changes stayed permenant, but hostname was
still resolving jtm64791.
Linuxquestions.org came to the rescue. It turned out to have a simple solution:
$sudo scutil --set HostName tarsier.domain.com
At the next reboot, the hostname was resolving
to tarsier. Great! So what else can we learn
from this?
According to its man page, scutil is a system
config parameter manager. More specificaly "it
is an interface to the 'dynamic store' data
maintained by configd(8)."
A quick man configd told me that the properties
were stored in a .plist file in
/Library/Preferences/SystemConfiguration. Of
course, OS X uses plist files for all sorts of
configurations, so it would make sense that
this would have been the place. I went ahead
and edited the xml formatted .plist in vi and
manually changed LocalHostName, computer name,
and HostName. Sure enough, on the next reboot
the name had changed.
Poking around the different .plist files in the
folder uncovers all sorts of neat
configurations. Of course, to make any changes
you will need to sudo or su as root. I was
happy enough with my newfound knowledge, and
chose not to try to break the computer. Be
careful making any changes you don't
understand.