Why is my host name wrong at the Terminal prompt when connected to a public WiFi network? [duplicate]
For three days straight, I have connected to the public WiFi network at my local library. Each day, I have seen a different prompt in Terminal. Here are some of the prompts I've seen:
zp-pc:~ russell$
mary-pc:~ russell$
normob05:~ russell$
I have check under System Preferences -> Sharing, and my computer name is "Russell's Mac". Also, I set the DHCP Client ID to "RUSSMAC" under System Preferences -> Network -> Advanced -> TCP/IP, but I still see the random host names at the Terminal prompt.
Why is my computer name changing every day?
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 ...
sudo hostname [name-of-host]
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
.