Repost Changing hostname in OS X
OS X: Changing Incorrect Hostname
Using The Terminal.
I have seen this issue many times. My OS X workstations receive the wrong hostname after being joining a Windows Active Directory Domain, and I have also read this can also happen on a standalone network, though am not quite sure what the circumstances might be as I have never operated outside a domain environment. You would not normally notice this, unless you frequent the Terminal.
You will notice, if you go to System Preferences > Sharing, it appears the hostname is set correctly. For example, the Computer Name shown here is the correct name, correct-hostname.
Now let’s open the terminal.app
You will see from the prompt, that your workstation has picked up the hostname of another computer on the network. It might look something like this, “Incorrect~ user$”
As you can see, the hostname is different than what displayed in the Sharing Preference Pane.
We Can verify this by entering the hostname command in the shell window.
prompt$ hostname
The shell returns the system hostname as:
incorrect-hostname.catracing.org
We know that’s incorrect, don’t we?
We could TRY and change the hostname by entering the terminal command hostname <correct-hostname.catracing.org>. However this will be lost upon reboot. Which would be quite pointless. We could also place it as a launchd item, or put it in a ~/.profile script. However there is a much cleaner and more appropriate method of doing this.
If you have SUDO configured (Which is the best practice)
At the terminal window, type the following.
Prompt$ sudo scutil --set HostName <newhostname>
Do not type the <>’s
If you do not have sudo configured, but have root enabled, su to root (Since I am in a domain environment, and my standard user account does not have administrator privileges I must first su to an account that does have administrator privileges either on the domain or a local administrator account.
Prompt# scutil --set HostName correct-hostname.catracing.org
Now type hostname at the terminal prompt
You should see
correct-hostname.catracing.org
Prompt$
Your actual terminal prompt may not change until you exit and relaunch the terminal.app
Comments
Repost Changing hostname in OS X — No Comments
HTML tags allowed in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>