Skip to main content

How to change your Mac's name using the OS X Terminal

John'sMacPro, begone!


Changing your computer's network name is something that can be easily done via System Preferences; however, if you have a Mac connected to your network without a display running as an iTunes or other media server, then you may only ever interact with your Mac via SSH in the Terminal.

If this is the case, then you can easily change the network name of your Mac via the Terminal with just a few tips that we'll show you in this article. Continue reading to learn all of the details.

Using this Terminal way of setting the computer name, you can easily fine tune how the computer is displayed to the network, and to Bonjour-based services that run on your network (such as Bonjour messaging). You cannot easily set these items separately in OS X's GUI.


To begin doing this, open the Terminal (located in /Applications/Utilities), or SSH into the Mac that you will be changing this setting on. Next, perform the following steps:

Type in the following command, replacing "name" with a user-friendly name that will identify the computer:

scutil --set ComputerName "name"

Once you press return, this name will be set. Next, type the following command, replacing "name" with the name that you wish to display on your local network to Bonjour-based services:

scutil --set LocalHostName "name"

Finally, you can also configure and set how the computer is displayed when connecting through SSH, and the name shown inside of the Terminal by typing the following command, replacing "name" with the name you want to use to display in the Terminal and when connecting to the machine over SSH:

scutil --set HostName "name"


Note: When specifying a LocalHostName and HostName, you should not have spaces in the name. After you press return for each of the items above, you will be prompted to enter your administrator password to authenticate the changes.

After you've set all of these items, you can type this command into the Terminal to ensure that the proper items were set:

scutil --get HostName

If everything looks good, then you can close the Terminal and enjoy the newly set names; otherwise, rerun any of the above commands again until you set the name you desired.