Change your Mac Hostname via Terminal

Here’s how to change a Mac hostname with the command line and make it permanent:

scutil --set HostName [new hostname]

Simply replace [new hostname] with whatever you want the hostname of your Mac to be changed to.

An example would be let’s say I want to change my Mac laptop’s hostname to MacBookPro, I will use this command:

scutil --set HostName MacBookPro

(Note the “–” before set is two dashes next to each other, –set)

You will be asked for your admin password since you’re using the sudo command. After the command is executed you can verify that the changes took place by typing:

You can also set a temporary hostname change by using the following command:
sudo hostname [new hostname]
This will reset itself after your Mac reboots though, so if you want a permanent hostname change, use the scutil command instead.

That’s all there is to it. By default Mac OS X will usually assign the hostname as whatever the admin account username is. Changing your Mac’s hostname can make it easier to find your Mac on a network and to connect to.

This was completely taken from the following website;, but I liked the way it was put and I don’t like reinventing the wheel.