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

南笙酒味 提交于 2019-12-21 03:51:08

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/21313163/how-to-fix-macbook-showing-android-hostname-in-terminal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!