Mac Won't Remember Hostname in Terminal After Reboot, gives 'unknown...'
Setting the hostname via the Terminal is not permanent.

From the hostname manpage:


  DESCRIPTION
  The hostname utility prints the name of the current host. The super-user can set the hostname by supplying an argument. To keep the hostname between reboots, run `scutil --set HostName name-of-host'.


Alternatively, set the hostname in your System Preferences, under the Sharing section.