To set the hostname:

 

scutil --set HostName server.yourcompany.com

 

To set the computer name:  Used via network browsing

 

scutil --set ComputerName “Keith’s Computer”

 

To set the local host name:  Used by Bonjour

 

scutil --set LocalHostName “Keith’s Computer”