Setting your Computer ‘Names’ – Command Line


Now some of you may not be aware that your computer even has 1 name, let alone 3, but here I will explain how to set them.
First, by default, your ‘Computer Name’ is set by the Operating System when you initially set your machine up, and it tends to use your account long name and the model of Mac, such as ‘John Smith’s MacBook Air’. I don’t like this as it gives away more information than I’d like, so you should change this by typing the following into Terminal, replacing the name within the quotes with the name you’d like to use

sudo scutil --set ComputerName "Mac1"

you can also change this by going to System Preferences, then Sharing, then changing the entry in Computer Name


Next you can change your Bonjour host name, your Bonjour host name is the name that shows up when you go to Finder and look under the Shared tab in the sidebar, to change this, open Terminal and type the following, again, replace the name in quotes with something of your own

sudo scutil --set LocalHostName "MBA1"


Finally, we have the hostname, this is the name which your machine can be reached from via the internet, through SSH normally, commonly this would be the DNS name of your machine. again, this would be changed through Terminal by typing the following

scutil --set HostName ""

I would recommend only using lowercase letters for this.
to confirm the changes have been successful, you can type the following into Terminal

scutil --get ComputerName
scutil --get LocalHostName
scutil --get HostName