The other day I was searching for Xcode iOS 5 tutorials. About a day or two later, I noticed my terminal prompt is now "iPhone4s : myusername". Naturally , my biggest fear is that there could be a worm or trojan horse on here. I look up the current procedure for checking the most current Mac Malware and the system turned up clean. I followed the examples to edit the PIF with the code:

PS1="\h : \u\$" 

and it does not get rid of the "iPhone4s" prefix. I checked the System Preferences > Sharing and the name for the computer is correct.

How do I go about making sure the system is not hacked, and how to get rid of the iPhone4s name? I have 3 accounts created on this system. The other 2 are not affected.

  • I had a similar scare today when I found "jairs-iphone" as my host name in the Terminal! I still don't know where it came from exactly since I've never connected to any iPhone, but ... the answers below helped a lot.
    – Matt
    Oct 31, 2012 at 1:52

5 Answers 5


It turns out it was just as our Unix guy had said. The iPhone4s Host name is only present when I am at work and my mac book is accessing the companies wireless network. When I am away, the terminal shows the proper hostname. We are a mac centric company but we use all windows servers. Apparently, that makes a situation ripe for these strange DHCP anomalies.

Thanks for the help.


I'm not sure why superuser migrated this here as this is a problem with your Mac and the router and not a phone, but just go to your sharing preference pane and change the name of your Mac. Be sure to pay attention to the Edit... button since your Mac could have adopted the name from a router thinking the IP address was for your phone and not your Mac.

You can use the hostname command to check things before and after you change things in the GUI.

  • 1
    No Its not a phone problem. I consulted with our Unix guy and he thinks its a coincidence that the terminal prompt shows that after I was looking for IPhone tutorials at home. he said we run a very large network here at work (and I am often patched into it) with Windows servers and I probably picked this up as a DHCP bug. There are lots of macs here(and other peripherals like Iphones etc). Thanks for the info
    – Miek
    Oct 1, 2012 at 22:45

I'm not sure how the name was changed and if it's at all possible to trace it back, but you can easily change the HostName to any name using the scutil command:

sudo scutil --set HostName your_new_name

Here's a shell script I use to change various computer names (ComputerName, HostName, LocalHostName) in one step:

# Change your computer names
# Run with sudo

# variables
computerName=$(scutil --get ComputerName)
hostName=$(scutil --get HostName)
localHostName=$(scutil --get LocalHostName)

    scutil --set ComputerName $id
    scutil --set HostName $id
    scutil --set LocalHostName $id

    printf "**************OLD SETTINGS*************\n"
    printf "ComputerName:   $computerName\n"
    printf "HostName:       $hostName\n"
    printf "LocalHostName:  $localHostName\n\n"

    newComputerName=$(scutil --get ComputerName)
    newHostName=$(scutil --get HostName)
    newLocalHostName=$(scutil --get LocalHostName)

    printf "***********CURRENT SETTINGS************\n"
    printf "ComputerName:   $newComputerName\n"
    printf "HostName:       $newHostName\n"
    printf "LocalHostName:  $newLocalHostName\n\n"

# main
if (($#==0))
    # print current names
    printf "***********CURRENT SETTINGS************\n"
    printf "ComputerName: $computerName\n"
    printf "HostName:     $hostName\n"
    printf "LocalHostName $localHostName\n\n"
elif (($#==1))
    # change name and print changes
    changeName $id      
    echo "Expected: Empty OR NewComputerName"

TLDR: It's weird but benign so you can ignore it.

This is an old question, but it has a cool answer so I'm sharing it.

It was answered here by the user that wrote the original question, and it seems like this happens over public wifi networks when your mack picks up a hostname from the DHCP server.

The answer linked this article which explains that it's caused by the domain server when it picks up on a previous user's hostname.

  • Thanks for the hint - I've linked the 2 questions on Ask Different.
    – Tetsujin
    Aug 12, 2018 at 17:03

This is likely because on a large network IP address your computer uses was previously associated with another device with a different name (the one appearing in your terminal).

I tried setting my hostname like gentmatt suggested but rather than use his code, the following worked for me:

sudo hostname <new-host-name>

To make it permanent, you can use the -s flag (supported since Mavericks):

sudo hostname -s <new-host-name>

See this article on OSX Daily.

Not the answer you're looking for? Browse other questions tagged .