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.

Right now I have a Mac Mini. I migrated macbook pro data from a time machine, but I didn't do it from the beginning of my startup. I used the migration assistance to migrate the data. However, I'm getting my macbook pro name in my terminal command line, why is that?

Name-Macbook-Pro:~ name$ 

Why am i getting this? I'm on my Mac Mini, I guess its from the migration but will it affect anything else? How do I change this?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

That part of the prompt is the hostname (\h) by default. Normally changing the computer name from System Preferences also changes the hostname:

The settings are stored in /Library/Preferences/SystemConfiguration/preferences.plist:

<key>Network</key>
<dict>
    <key>HostNames</key>
    <dict>
        <key>LocalHostName</key>
        <string>Lauris-iMac</string>
    </dict>
</dict>
<key>System</key>
<dict>
    <key>ComputerName</key>
    <string>Lauri’s iMac</string>
    <key>ComputerNameEncoding</key>
    <integer>0</integer>
</dict>

This changes the system hostname:

sudo scutil --set HostName My-MacMini

It adds <key>HostName</key><string>My-MacMini</string> under System. If the system hostname has been set, changing the computer name or local hostname from System Preferences won't change the prompt.

share|improve this answer
    
THanks! changing the computer name solved the problem! –  andrewliu Apr 11 '13 at 5:31
    
+1; I conclude that there's no good reason to ever set HostName (despite what man hostname says!), given that its value is then out of sync with the LocalHostName value set via System Preferences. Conversely, LocalHostName is also recognized by hostname. To put it another way: if you want to change the hostname from a shell, use BOTH sudo scutil --set LocalHostName newName and sudo scutil --set ComputerName newName, where the ComputerName value can be a friendlier version (spaces, punctuation) of the LocalHostName value (alphanumerics and dashes only). –  mklement May 5 at 4:28
    
To get rid of a HostName entry, set its value to an empty string (this effectively removes the key from the .plist file): sudo scutil --set HostName ''. –  mklement May 5 at 4:31
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.