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

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set my hostname for my mac. Currently it's unknown002374e31ebd.

I've tried setting it with

sudo hostname -s Steve-Mac

Which will work for all future terminal sessions. However, if I restart, it goes back to unknown

How can I get it to keep this setting?

share|improve this question
up vote 4 down vote accepted

Setting the hostname via the Terminal is not permanent.

From the hostname manpage:

The hostname utility prints the name of the current host. The super-user can set the hostname by supplying an argument. To keep the hostname between reboots, run `scutil --set HostName name-of-host'.

Alternatively, set the hostname in your System Preferences, under the Sharing section.

share|improve this answer
Additionally, -s does not stand for "set". Also from the manpage: -s Trim off any domain information from the printed name. – Jason Salaz May 2 '13 at 9:14
in my version of scutil, -s doesn't stand for anything, I get the following error when I try to run scutil -s HostName Foobar: scutil: invalid option -- s – Alexej Magura Jan 15 '14 at 14:10
I was talking about hostname -s not meaning what OP thought it meant. Indeed, scutil doesn't have a -s option. – Jason Salaz Jan 16 '14 at 22:21

Fastest way is to setup it in System Preferences -> Sharing (unlock screen by clicking padlock on bottom) and then change name and Apply.

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.