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.

My computer name in System Preferences > sharing is set to "archos" but is showing as "iphone" on the terminal. It just started doing this after I loaded Xcode for doing iPhone development.

Last login: Mon Nov  7 14:46:55 on ttys001
iphone:~ travis$ 

Any ideas what could be causing this?

share|improve this question
what do you get when you type echo $HOSTNAME –  Daniel Lawson Nov 8 '11 at 6:14
this is weird...I am getting 'archos.local' for echo $HOSTNAME. I did the initial writeup when I was at the office, but on my home network it is back to normal. I wonder if this has something to do with my work network? –  Travis Nelson Nov 8 '11 at 6:45
add comment

4 Answers

up vote 15 down vote accepted

It's perfectly normal for this to occur; when you login Terminal remotely bash does a reverse DNS lookup. It will only be the same if the hostname is not specified on the network you're connecting from and there is no reply from the DHCP server, or the reverse lookup against the remote DNS server fails to resolve.

You can easily over-ride the default setting by using this command in Terminal:

# sudo scutil --set HostName archos

You can check it by using:

# nslookup nn.nn.nn.nn
( or )
# host nn.nn.nn.nn

(where nn signifies your Mac's ip address)

share|improve this answer
How can you undo that? –  Gio Dec 1 '11 at 18:45
@Gio Delete the HostName key under System from /Library/Preferences/SystemConfiguration/preferences.plist. See this answer. –  Lauri Ranta May 9 '13 at 10:42
add comment

You may also want to change some other things using the scutil command:

sudo scutil --set ComputerName "newname"
sudo scutil --set LocalHostName "newname"
sudo scutil --set HostName "newname"
share|improve this answer
By changing the name in System Preferences->Sharing and then using scutil to set HostName, both ComputerName and LocalHostName were already set to the new name for me (in Mavericks). Nice to know that these other settings exist, though. –  Jim Stewart Nov 15 '13 at 19:02
add comment

In addition to Jeffrey J. Hoover's tip (above),

I would add these last two steps:

  • Flush the DNS cache by typing: dscacheutil -flushcache
  • Restart your Mac.
share|improve this answer
add comment

I agree that Jeffrey Hoover's tip was the correct answer. Flushing the DNS cache and restarting the Mac is a nice step too. This is variant of Jeff Hoover's reply:

sudo -i

for n in HostName ComputerName LocalHostName; do scutil –set $n new_hostname; done


share|improve this answer
add comment

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.