Sign up ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I've got a handleful of macs (all with unique names) and on occasion it prompt a notice about saying another computer on the network as this name and adds a (2) or (3) to my mac.

How can I set the host name from the command line?

share|improve this question
You need to clarify this into an actual question rather than a discussion topic - I can do it for you, but seems fair to give you the chance. –  stuffe Oct 21 '11 at 19:11
What router do you have? Have you enabled wake for network access on the problem macs? –  bmike Oct 21 '11 at 19:21
It's a sonic wall NSA 3500. It's a school –  Bradley Chambers Oct 22 '11 at 11:27
Not enabled for network access from sleep –  Bradley Chambers Oct 22 '11 at 11:32

2 Answers 2

There is a couple ways to go about solving this problem.

The immediate change is to to open up Terminal, and issue the command

sudo scutil --set HostName {your machine name here}

The next thing to do is to

sudo pico /etc/hostconfig

Add the following line, followed by Ctrl+O, and then Ctrl+X

HOSTNAME={your machine name here}

Finally reboot

share|improve this answer

Yes you can :

sudo scutil --set HostName "YourHostName"
sudo scutil --set LocalHostName "YourLocalHostName"

to change the computer name :

sudo scutil --set ComputerName "YourComputerName"

To check if everything is okay : sudo scutil --get HostName

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.