Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix MacBook showing Android hostname in Terminal? [closed]

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

like image 846
Danny Green Avatar asked Jan 23 '14 15:01

Danny Green


1 Answers

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.

like image 138
chepner Avatar answered Oct 27 '22 02:10

chepner