Change the hostname in Mac OS X [osx]
When I log into the network at my job my Mac’s hostname always turns to:
larryx.na.corp.ipgnetwork.com
I have my local hostname set to:
larryx.local
So What I would like to do is set my Mac’s hostname to my local hostname. You can do this all from Terminal in a single line.
Run this command in Terminal:
sudo scutil --set HostName larryx.local
This is also helpful if you’re in Terminal and have a really long hostname at your prompt. If you want to view your current hostname, run this command in Terminal:
hostname
Update (February 13, 2012): Some people have reported that their hostname is not updating. Please try closing your current Terminal session and starting up a new one. Then type “hostname” and you should see your changes.
This is what it looked like for me:
Last login: Fri May 23 09:55:20 on ttys000
larryx:~ lgordon$ hostname
larryx.na.corp.ipgnetwork.com
larryx:~ lgordon$ sudo scutil --set HostName larryx.local
Password:
larryx:~ lgordon$ hostname
larryx.local
Care of: CodeSnippets
Update (March 29, 2011): After making this post I never thought that this would have helped so many people out there. I’m really glad that this has helped you and I thank you for your kind words.
Pingback: Just wondering…. » Blog Archive » MacOSX and hostname
Pingback: Bits And Pix » OSX: Set Mac hostname (i.e. avoid perforce workspace issues)
Pingback: Trocando o Hostname no Mac OS | @Italux
Pingback: links for 2011-01-12 « Midashuang's Blog
Pingback: Fix XAMPP HostnameError001 on Mac OS X « Larry Gordon
Pingback: Hack your Mac | Pearltrees