macOS: Wrong Bonjour name stuck in hostname Due to a network problem, my iMac was renamed Theater-ATV-8.localname.  This is the name that appears when the Terminal hostname name is run.  

Nothing I have tried will change this name permanently. I can change it with hostname [new name], but it reverts on reboot.

The name in the Sharing pane in System Preferences if KW-desk-iMAC.
The man page for hostname says:


  To keep the hostname between reboots, run `scutil --set HostName name-of-host'.


Also, the name in the Sharing prefs pane you mentioned, is that the name that isvisible right there when you open the pane, or the one you can edit when you click the "Edit..." (or similar - in German it's "Bearbeiten...") button?