12

I use terminal quite often, for some reason all of a sudden Terminal is showing a strange android-1e1c8882e08308f9 hostname (see image) in the prompt.

I've checked my MacBook's hostname in Sharing Preferences and this is correct, but Terminal is still showing the android hostname.

Can anyone advise?

Thanks

Terminal Screenshot

thomasfedb
  • 5,990
  • 2
  • 37
  • 65
Danny Green
  • 325
  • 4
  • 13
  • 1
    You may be getting a different host name from your DHCP server. – chepner Jan 23 '14 at 16:02
  • You may be right, I'm using a public WiFi connection at the moment. I'll see if it fixes itself when I get home. Thanks! – Danny Green Jan 23 '14 at 16:04
  • What does the `hostname` command show you? – glenn jackman Jan 23 '14 at 16:13
  • Related: http://apple.stackexchange.com/questions/30552/os-x-computer-name-not-matching-what-shows-on-terminal and http://superuser.com/questions/357159/osx-terminal-showing-incorrect-hostname – tripleee Jan 23 '14 at 18:20
  • http://reviews.cnet.com/8301-13727_7-10362633-263.html suggests editing `/etc/hostconfig` to add `HOSTNAME=yourhostname` at the end. – tripleee Jan 23 '14 at 18:22

1 Answers1

12

By default, the host name of your computer is not set. The Sharing panel lets you set the computer name, which is a Mac OS X-specific attribute. My theory is that if the host name is not set, hostname (and your shell prompt) will use this value instead. The following is the output of scutil and hostname on my laptop.

patikoija ~ % scutil --get ComputerName
patikoija
patikoija ~ % scutil --get LocalHostName
patikoija
patikoija ~ % scutil --get HostName
HostName: not set
patikoija ~ % hostname
patikoija.local

When I visit my company's office, my host name is similarly set to something that begins with 'dhcp-'. I suppose that the DHCP server sets the actual host name, and running scutil there would show that name. You can try using scutil to set the true host name of your computer, and see if that "resists" efforts by the DHCP server to override it.

chepner
  • 497,756
  • 71
  • 530
  • 681