Apple - Why is my host name wrong at the Terminal prompt when connected to a public WiFi network?

Type in Terminal:

scutil --get HostName

If there's no HostName available, what you see is probably coming from the DNS or DHCP server.

Set your HostName with:

sudo scutil --set HostName 'yourHostName'

That should do it.


Found the answer here, though there is some discussion about the details.

In short, the Mac will pick up a host name from the DHCP server. This does not affect your computer's name as you have assigned it. This will only affect what you see at the command prompt.


Very simple easy solution ...

  1. sudo hostname [name-of-host]

  2. Enter hostname and see your new hostname set

e.g.

doolally:~ sjohnson$ sudo hostname AllTheRage
doolally:~ sjohnson$ hostname
AllTheRage

Login back in or restart terminal to refresh ...

Also, check usage of hostname in man hostname.