Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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
add comment

2 Answers 2

up vote 3 down vote accepted

Setting the hostname via the Terminal is not permanent.

From the hostname manpage:

DESCRIPTION
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
1  
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 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 at 22:21
add comment

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
add comment

Your Answer

 
discard

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.