Skip to main content
Question

Unset HostName (after scutil used to set)

  • August 7, 2015
  • 13 replies
  • 30 views

donmontalvo
Forum|alt.badge.img+36

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?

13 replies

Forum|alt.badge.img+18
  • Valued Contributor
  • 1007 replies
  • August 7, 2015

why would you want to do that? Out of curiosity.


donmontalvo
Forum|alt.badge.img+36
  • Author
  • Hall of Fame
  • 4293 replies
  • August 7, 2015

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.


Forum|alt.badge.img+5
  • Contributor
  • 59 replies
  • August 7, 2015

I seem to recall using

scutil --set HostName ""

in the past, though I could be wrong...


donmontalvo
Forum|alt.badge.img+36
  • Author
  • Hall of Fame
  • 4293 replies
  • August 7, 2015

Yep, tried that...it sets hostname to:

""

Haha


Forum|alt.badge.img+5
  • Contributor
  • 59 replies
  • August 7, 2015

Nice :) how about removing the HostName key from /Library/Preferences/SystemConfiguration/preferences.plist?


Forum|alt.badge.img+16
  • Honored Contributor
  • 404 replies
  • August 7, 2015

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 :)


Forum|alt.badge.img+12
  • Employee
  • 58 replies
  • August 8, 2015

here are my results:

b...$ scutil --set HostName ""
b...$ scutil --get HostName
HostName: not set

donmontalvo
Forum|alt.badge.img+36
  • Author
  • Hall of Fame
  • 4293 replies
  • August 8, 2015

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$

bradtchapman
Forum|alt.badge.img+20
  • Valued Contributor
  • 588 replies
  • August 9, 2015

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."

@donmontalvo,

  1. Are these machines under management by Casper?
  2. Are there any profiles in System Preferences?
  3. Are there any managed preferences in /Library/Managed Preferences/ ?
  4. Are these machines fresh installs or migrations?

donmontalvo
Forum|alt.badge.img+36
  • Author
  • Hall of Fame
  • 4293 replies
  • August 9, 2015

@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.


donmontalvo
Forum|alt.badge.img+36
  • Author
  • Hall of Fame
  • 4293 replies
  • August 9, 2015

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.


russeller
Forum|alt.badge.img+15
  • Valued Contributor
  • 216 replies
  • August 10, 2015

+1 for @donmontalvo high res Picard.


Forum|alt.badge.img+12
  • Contributor
  • 529 replies
  • August 12, 2015

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