AFP548 Site News March 2, 2020 at 7:53 am

Name Goes Here, code bass=”clash”

On the Twitters not too long ago the question was posed: what topic could you give a 20 minute talk about without any prep? macOS Computer Naming is a thing I can’t find a great canonical resource for on the internets, so here’s an attempt to fill that gap, since the topic would potentially be shorter than 20 minutes, but as it’s said: they go low, we go deep.

What’s in a name?

Names are just labels. Your inventory and/or management system could contain an identifier like the serial number, hardware UUID, MAC address, and/or device certificate to more accurately track a computer (and help with linking it to a user), so IMO it’s not necessary to stop people from renaming their computer in System Preferences in general. We all know that by default it chooses the computer model to name itself, and on a home computer will update that name with whoever was the user created in Setup Assistant (E.g. Testy McTesterston’s Compy386).

It could be that your management tools are… silly, or security agents only pick up that easily-changed name and therefore you need to extract whatever other unique identifier may be stored locally on the client and ship it to the aforementioned mythical inventory tool for correlation. What those vendors of silly tools might need a primer on is the actual three possible labels we could be using for ‘name’ information on a Mac, as query-able by scutil, a mnemonic for system configuration utility. Let’s do it!

  1. ComputerName – that’s the label we’ve been referring to above, accessible from the System Preferences → Sharing preference pane. Some docs historically have referred to it as the ‘user-friendly’ name, one claim to fame is that Apple Remote Desktop leverages this e.g. in school lab environments.
  2. LocalHostName – this designates the computer on a local broadcast domain or subnet/vlan. This is the name that will be visible through file sharing such as AirDrop, and is critical to ZeroIP/Bonjour (also formerly Apple-branded as Rendezvous) addressing for computers so services can benefit from name resolution even when the device only has a link-local address or otherwise doesn’t have DHCP.
  3. Fun Fact!
    Ever see Computer Name (2) or similar number increments in parentheses? That could be because a resolution lookup returned the local name and Apple’s framework told the computer to keep incrementing until it saw an unused increment. In more rocky releases of macOS, it was thought to even occur just if both WiFi and Ethernet were connected to the same network…

    When setting ‘ComputerName’ in System Preferences → Sharing, the change is inherited by this value, but you’ll see it append ‘.local’ in the text below that field.

  4. HostName – by default, this is not set on out-of-the-box computers, and in testing we see the hostname command inherits the LocalHostName as a substitute. That default ‘unset’ state would result in the bash or zsh prompt matching the LocalHostName, unless HostName is set, in which case both prompt and the hostname command would use that. This is also why opening a terminal/command prompt may show a random name pulled via some quirk with name resolution on that particular network.
<code class="bash">~ allister$ scutil --get HostName
HostName: not set
air:~ allister$ scutil --get ComputerName
air:~ allister$ hostname
air:~ allister$ sudo scutil --set LocalHostName michaeljordon
air:~ allister$ hostname

Last login: Tue Nov  5 15:16:11 on ttys000
michaeljordon:~ allister$

In many business settings, all three names are set to the same value at deploy time, and management tools sometimes enforce this. Some prefer to base device certificate names off the UUID or serial or a combination of derived values when applicable.

Thank you for coming to my Ted Talk, and belated welcome to 2020!

Allister Banks

Allister lives in Japan, has not read the Slack scroll back, and therefore has no idea what is going on.

More Posts - Website

Follow Me:



  • Hey, Allister, welcome back! Looks like a two year break in AFP548.

  • [dry humor warning]

    I’m afraid this article is slightly incorrect. There is, in fact, an RFC that offers some excellent guidance on host naming. It agrees that each host MUST have three different names, however the details diverge somewhat.

    I would recommend a read of for more information.

Leave a reply

You must be logged in to post a comment.