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

Oct 24, 2012 - 7 Comments

Set Unique Hostname, Computer Name, Bonjour Name in Mac 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.

How to Set Individual Computer Names, Host Names, and Bonjour Names on Mac

To get started, launch Terminal from /Applications/Utilities/ as this walkthrough requires the use of the command line. It’s also important to note the — is a double-dash, not a single – flag.

Set Individual Computer Name in Mac OS X with scutil

ComputerName is the so-called “user-friendly” computer name for a 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"

How to Set Unique HostName in Mac 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"

How to Set Unique LocalHostName in Mac 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 Mac 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:

How to Get Current Host Name, Computer Name from Mac Command Line

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

Getting the host name:

scutil --get HostName

Getting the computer name:

scutil --get ComputerName

Getting the Bonjour local host name:

scutil --get LocalHostName

For these examples, the HostName, Bonjour Name, or Computer Name will be reported back, and if one is not set it will tell you.

.

Related articles:

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

7 Comments

» Comments RSS Feed

  1. Wiser says:

    This is especially useful to keep macOS from changing the hostname whenever it connects to a WiFi that want’s to assign a name via DHCP. A constantly changing hostname has all kinds of consequences, none of them the good kind.

  2. Arasu says:

    How to change
    ambalatharasusigamani@AmbalatarasuMac ~ %
    @AmbalatarasuMac in above line

  3. nipszx says:

    Somebody please help. My Macbook is running at 180 degrees and is smoking hot. When I open up Activity monitor “scutil” is using up 80% and when I quit the process my Mac cools down. How can I quit “scutil” for good and keep it from reappearing as a CPU hog?

  4. CB says:

    How do you change the name machine name TacoTown?

  5. 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 on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

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

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site