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:
hostnameThis 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
{ 9 comments… read them below or add one }
Hi,
How are you? I am trying to set up on Mac similiar to your.
Hostname
melissa.na.corp.abcxyz.com
etc/hosts don’t change this entry. echo $HOSTNAME. It returns melissa-imac.local.
No HOSTNAME file in etc/.
Where should I backup or begin?
Thanks,
suredazzle
Nice tip, thanks. I was looking to change hostnames of my MacBook and iPhone. Turns out it works on both.
Thanks! Apple’s support site was no help!
For some reason the command suggested doesn’t work at all for me:
[dpo@pod:~ ]$ hostname
pod.local
[dpo@pod:~ ]$ sudo scutil –set HostName rocky
Password:
[dpo@pod:~ ]$ sudo scutil –get HostName
rocky
[dpo@pod:~ ]$ hostname
pod.local
Any ideas? I am running 10.5.8. I have to change the hostname from time to time to make some grumpy license managers happy. Editing /etc/hostconfig works but is less elegant.
Dom, make sure you use double dashes, e.g. “–set” when you enter the
“Sudo scutil –set HostName” command.
How ya doing? You picked the ones closed to my heart too, despite the fact I know I am guilty of #1 when I don’t pay attention.
Tahnks a lot, your solution really works, it is the only place I found where it says how to do it, apple solution doesn’t work.
This is awesome! It works perfect for me. As much as I love my Mac, there are some things that I wish were more straightforward UNIX-y.
Great! It worked well, thank you.
Notice that if you change the hostname this way you may need to restart (or re-log into) the machine because the internet / lan may go down. It seems that bonjour or other name-resolving services can’t figure out that the hostname is changed and don’t update the name.
Bye!
{ 2 trackbacks }