105

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?

grg
  • 201,078
  • See also http://apple.stackexchange.com/questions/30552/os-x-computer-name-not-matching-what-shows-on-terminal – rogerdpack Dec 19 '14 at 17:31

5 Answers5

167

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.

JackyJohnson
  • 1,840
39

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.

klanomath
  • 66,391
  • 9
  • 130
  • 201
  • 2
    It's a short discussion of this exact issue. The conclusion is that you're seeing a name that was given to you by the computer that assigned you an ip address. In other words, the library's wifi gave me a random name that it picked up from some other computer that previously connected to their wifi. – Russell Thackston Dec 14 '14 at 01:58
  • 1
    what was the "answer" mentioned then? Just that it's benign to go ahead and ignore? – rogerdpack Dec 14 '14 at 07:02
  • Correct. BTW, the link is working now. It looks like klanomath fixed it. – Russell Thackston Dec 17 '14 at 12:31
  • Same story. Renaming computer in "Sharing" preferences not changed host name everywhere. Host name in Terminal and Hints in "Sharing" preferences were not up to date. Also in "Networking" preferences "WINS -> NetBIOS Name" was wrong. Restarting WiFi Access Point resolved an issue. – Vlad Mar 10 '23 at 20:52
7

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.

nohillside
  • 100,768
1

I noticed my hostname listed in the terminal prompt had changed. I found the same name configured in my network settings in the WINS tab. Seemed to be associated with a workgroup from my office (perhaps from connecting to my corporate VPN). Anyhow, I left it alone and simply used the sudo scutil command listed above to set my hostname and it resolved the issue. Closed terminal and opened a new one; all is good.

-1

This is very late, but hopefully this helps those in the future who run into this problem. After a lot of research the somewhat long but most simple answer I found was to:

  1. Open System Preferences > Network
  2. Click the location dropdown menu
  3. Select "Edit Locations..."
  4. Click the plus button to add a new location
  5. Add a new location by giving it a name
  6. Click Done
  7. Click Apply (instructing it to use the new location)
  8. Open new Terminal window

That should do it.