Code Blog

Displaying 1-1 of 1 result.
2017/03/31 MacOSX

I had a problem when starting a new terminal window (running bash shell) that the hostname displayed was wrong, and was actually instead showing different network connected hostnames. To fix this, first check if hostname is set on the local machine, to do this type the following in the terminal:

scutil --get HostName

If there's no hostname set for the local machine, then is can be defined with this command:

sudo scutil --set HostName 'computerHostName'

After restarting the terminal window the hostname was showing correctly in my case. Another way to fix this is to just change the prompt for the shell (edit the ~/.bash_profile if running bash), but I think this is a better way to resolve it. It is a bit confusing with hostname / computer name / local hostname as they are used in different parts of Mac OS for bonjour and sharing. In this case it seems as I didn't have a hostname defined, the system instead got another hostname from the DNS server.