Open the Terminal (located in /Applications/Utilities), or SSH into the Mac that you will be changing this setting on. Type the following command, replacing “name” with the name you want for your Mac and press enter:
Type the following command, replacing “name” with the name that you want for your local network to Bonjour-based services:
Set how the computer is displayed when connecting through SSH, and inside 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:
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.
Now, you can use these commands in Terminal to ensure that the proper items were set, using HostName, LocalHostName or ComputerName. Enter each of these separately:
You can flush the DNS cache with the following but this is not necessary:
Note: By default, there is no “Host Name” set on a Mac.