Change your Mac Hostname via Terminal

Here’s how to change your Mac hostname with the command line and make it permanent:
scutil –-set HostName new_hostname

You can also set a temporary hostname change by using the following command:
sudo hostname new_hostname