Posted on 08-07-2015 10:47 AM
The scutil doesn't appear to have a reliable way to undo HostName that was set.
man scutil seems to indicate putting no value in the command will undo it, but doesn't seem to work.
--set pref [newval]
Updates the specified preference with the new value. If the new value is not specified on the com-
mand line then it will be read from standard input.
Supported preferences include: ComputerName LocalHostName HostName
The --set option requires super-user access.
What's the magic pill to undo HostName?
Posted on 08-07-2015 10:56 AM
why would you want to do that? Out of curiosity.
Posted on 08-07-2015 12:43 PM
To be clear, we never set HostName. We discovered it is set on some Macs. Trying to remove the setting.
Look through old threads, I've always been like "Why are you doing that?!" so we are on the same page. ;)
Cleaning up.
Posted on 08-07-2015 12:50 PM
I seem to recall using
scutil --set HostName ""
in the past, though I could be wrong...
Posted on 08-07-2015 12:54 PM
Yep, tried that...it sets hostname to:
""
Haha
Posted on 08-07-2015 01:00 PM
Nice :) how about removing the HostName key from /Library/Preferences/SystemConfiguration/preferences.plist?
Posted on 08-07-2015 04:05 PM
You must be doing something weird because when I set it to "" it goes back to "not set". I blame you Don ;)
Though if you really want to blow it away you could edit the /Library/Preferences/SystemConfig/preferences.plist file. Or just throw it away and restart. It will set your computer name to local host and remove the other versions of the host name.
Edit: Must have been typing at same time :)
Posted on 08-07-2015 06:15 PM
here are my results:
b...$ scutil --set HostName ""
b...$ scutil --get HostName
HostName: not set
Posted on 08-08-2015 07:58 AM
Thanks for all the feedback. I tested on 10 more Macs, and 4 had the problem, but 6 didn't.
I'll have to sift through our policies/mcx/configprofiles to see if something is doing this.
Here is the sanitized output from one of the effected Macs.
MyComputer:~ myshortname$ scutil --get HostName
MyComputer
MyComputer:~ myshortname$ sudo scutil --set HostName
Password:
HostName [MyComputer]: ""
MyComputer:~ myshortname$ scutil --get HostName
""
MyComputer:~ myshortname$
Posted on 08-09-2015 03:27 PM
I tested this on OS X 10.10 "Vegemite" and OS X 10.11, "El Capitan & Tennille."
Manually setting the hostname to "1234" on both machines did exactly what it should. The Computer Name and LocalHostName were unaffected. Setting it back to "" on both machines resulted in "Host Name: Not Set."
Posted on 08-09-2015 04:14 PM
@jonscott and @chriscollins thanks we're hoping to avoid editing that file. I'll have a look at the areas I mentioned to see if it's being set somewhere.
Posted on 08-09-2015 04:56 PM
Hi @bradtchapman,
In response to #4 on your post (the rest has already been hashed out), we sampled a mix of both. So as we mentioned already in the thread, we're going to have a look at those areas. It looks like something is being set somewhere.
There is also a chance someone pushed out a command to set HostName because Google told them to so it. We've seen this is a fair number of large environments.
Underscores the importance of having a programmatic/modular approach, rather than creating a monolithic/baked-in environment mess.
Posted on 08-10-2015 01:35 PM
+1 for @donmontalvo high res Picard.
Posted on 08-11-2015 06:05 PM
It's how you are using the command, the interactive escapes the quotes.
ml0637:/ root# scutil --get HostName
HostName: not set
ml0637:/ root# scutil --set HostName ML0637
ml0637:/ root# scutil --get HostName
ML0637
ml0637:/ root# scutil --set HostName
HostName [ML0637]: ""
ml0637:/ root# scutil --get HostName
""
ml0637:/ root# scutil --set HostName ""
ml0637:/ root# scutil --get HostName
HostName: not set
ml0637:/ root# scutil --set HostName """"
ml0637:/ root# scutil --get HostName
""
ml0637:/ root# scutil --set HostName ""
ml0637:/ root# scutil --get HostName
HostName: not set