Set the HostName, Computer Name, and Bonjour Name Separately in OS X

Oct 24, 2012 - 2 Comments

Set Hostname, Computer Name, Bonjour Name in OS X

You can set unique names for how your Macs computer name appears locally, from file sharing and networking, and even Bonjour services, with the help of the scutil command. This allows you to have a custom hostname for Terminal and SSH, another friendlier name for what’s visible to others on local networks, and yet another name only visible to services like AirDrop. Here’s a brief look at each and how to set them from the command line.

To get started, launch Terminal from /Applications/Utilities/. Note the — is a double-dash, not a single – flag.

Set ComputerName in OS X with scutil

ComputerName is the so-called “user-friendly” name for the Mac, it’s what will show up on the Mac itself and what will be visible to others when connecting to it over a local network. This is also what’s visible under the Sharing preference panel.

scutil --set ComputerName "MacBook Willy"

Set HostName in OS X with scutil

HostName is the name assigned to the computer as visible from the command line, and it’s also used by local and remote networks when connecting through SSH and Remote Login.

scutil --set HostName "centauri"

Set LocalHostName in OS X with scutil

LocalHostName is the name identifier used by Bonjour and visible through file sharing services like AirDrop

scutil --set LocalHostName "MacBookPro"

Of course there’s nothing wrong with using the same name for each example as well, which is actually the default behavior of OS X.

Having individual settings will be unimportant for the majority of Mac users, but setting a custom computer name is always a good idea, though novice users are best served through the Sharing preference panel. If you do want to venture off into the command line, it may be helpful to view the brief video below which demonstrates scutil changing the hostname of a Mac OS X machine:

Finally, you can also check the current settings of LocalHostName, HostName, and ComputerName by using scutil with the –get flag like so:

scutil --get HostName

For that example, the HostName will be reported back, and if one is not set it will tell you.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: William Pearson in Command Line, Mac OS X, Tips & Tricks

2 Comments

» Comments RSS Feed

  1. Christi says:

    hi how to change the name “OSXDaily” ???

    • Cap'n Slipp says:

      @Christi: If you meant “how to change _to_ the name ‘OSXDaily’”, the commands would be0 something like this (exact naming choices are up to you):

      scutil –set ComputerName “OS X Daily”
      scutil –set HostName “osxdaily”
      scutil –set LocalHostName “OSXDaily”

      Note that ComputerName is fully human-friendly— spaces, punctuation, etc.  LocalHostName still has caps, but no spaces— OS X by default takes the ComputerName and puts hyphens in where spaces and other characters would be (e.g. “OS-X-Daily”).  HostName is the UNIX-friendly version— only lowercase, and rarely hyphens (although they’re allowed), kind of like a domain name before the “.com” TLD part.

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates