Categories: Command-Line

Chris Manning

Share
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:
Copy to Clipboard
Type the following command, replacing “name” with the name that you want for your local network to Bonjour-based services:
Copy to Clipboard
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:
Copy to Clipboard

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:
Copy to Clipboard
Copy to Clipboard
Copy to Clipboard
You can flush the DNS cache with the following but this is not necessary:
Copy to Clipboard

Note: By default, there is no “Host Name” set on a Mac.

Leave A Comment

Related Posts