Previous 1 2 3 Next 30 Replies Latest reply: Jul 13, 2009 8:47 PM by Jun T.
nerowolfe Level 6 Level 6 (13,065 points)
The terminal prompt reads
new-host:~ nero$
It normally starts with

This happened once before when my computer's name mysteriously changed to xxx (2) but after renaming the computer back to the original name, the terminal prompt also returned to normal.
This morning it's as shown above but the computer name is correct and has not changed.

I trashed the terminal preference file and repaired permissions (not that I thought it would help) and the prompt is still incorrect.

How to fix this? Where does the prompt get the computer name from? I presume it should automatically pick it up from the network settings or the computer name under sharing, but both those are correct.
And yes, I have rebooted, also no no avail.
I am looking through console logs, but don't see anything obvious yet.

Message was edited by: nerowolfe

Message was edited by: nerowolfe

MacBookPro3,1-17"Core2Duo/VistaUlt64SP1; MacBookPro1,1-15"/XPProSP3; Dual G5/XPP, Mac OS X (10.5.7), Homebrew 3GHz ASUS PC, Dell Inspiron8k, Abacus, Sliderule, HP-50G
  • nerowolfe Level 6 Level 6 (13,065 points)
    That doesn't help
    echo $PS1
    I get
    \h:\W \u\$
    which is as it should be,
    where of course, the \h: means that it should be showing the hostname, and it is not - it is showing new-host which is not the hostname.
    I need to know where and why the terminal is picking up the incorrect name.
  • Bang A. Lore Level 2 Level 2 (180 points)
    Read the entire thread, or one of the many virtually identical threads which have been posted in the past.
  • nerowolfe Level 6 Level 6 (13,065 points)
    I see nothing useful.
    I suspect it's a cache issue.
    After a boot into the safe mode and then back to normal, the terminal prompt now reads
    new-host-2:~ nero$
    so, to me, it's a cache problem - but which one?

    My original question is simple - from where does the terminal get the computer name?

    Message was edited by: nerowolfe
  • Jeffrey Jones2 Level 6 Level 6 (8,615 points)
    The hostname usually comes from the local network or from your ISP. You can use the hostname command to see what your full hostname is. For some reason, this is the third time I have seen this question today.

    See also

  • BobHarris Level 6 Level 6 (16,415 points)
    From the same place the hostname command gets the host.

    man 1 hostname
    man 7 hostname
    man 3 gethostname

    Generally speaking this comes from the IP address (DHCP assigned IP address maybe), and then a reverse DNS lookup of the IP address to what the DNS server/DNS cache thinks is the name associated with that IP address.

    You could try flushing your DNS cache, but that will not stop the DNS server from providing the same values again:

    dscacheutil -flushcache # Leopard
    lookupd -flushcache # Tiger

    My work hostname looks like:

    I personally do not like this, so I changed my .bashrc so that it explicitly sets my PS1 variable to a name string I desire.

    Because I use the same .bashrc file on several systems, I make some tests to see which Mac, Linux, Solaris, AIX system I am currently on. It is a bit complex, but it works for me, and avoids using the dhcp-location-x123-abcd-xx-xxx-xxx-xxx name.
  • nerowolfe Level 6 Level 6 (13,065 points)
    Hi Bob,
    I did some further digging after the terminal name became "new-host-2" and I think it's my router doing the dirty
    The router shows two computers for this box, the correct name and the new-host name.
    Not so curiously, in Sharing Preferences, under File Sharing, the text says that my computer is available at both locations as below:

    Other users can access shared folders on this computer, and administrators all volumes, at afp://new-host-2.home/ or "nerombp17".

    I suspect that my router is being confused when I switch from Ethernet to WiFi, but at this point I am not sure, but it does seem that way when I browse my router GUI.

    I only noticed this because it's unusual and new and those things are triggers for me.
    This is the only computer that uses both Ethernet and WiFi and it's possible that they can both be on at the same time - I am not sure.
    I don't know if the router is the cause or the result but I suspect the former.
    I don't have any Windows boxes on at this time, and my other MBP which is connected via WiFi does not show any problems, and in the Finder on that box, this computer shows up with the correct name, not the new-host name.

    I think I will reboot the router - not simply turn it off/on but do the full reset using the button.
    I will then reboot this box and see what happens.
    Since I am the infinitely curious type, these kinds of things are quite interesting and I don't let them go until they are resolved.
    It certainly is an interesting issue.
  • BobHarris Level 6 Level 6 (16,415 points)
    Maybe you could try giving your Mac a fixed IP address (outside your router's DHCP range), assuming this is a typical home router situation and not a corporate router.

    Give your Airport and your Ethernet interfaces the *EXACT SAME* fixed IP address.

    I suspect that might stop your router from assigning new names to your Mac.

    With this configuration you can switch between Airport and Ethernet and back again, always keeping the same IP address. With an identical fixed IP address on both ethernet and Airport you can even do this while in the middle of a file transfer and not miss a beat, except that in home transfers speed up when switching to etherent and the other system is also on ethernet.

    The Mac has an ordering to its networking interfaces, and as long as your Ethernet is higher in the list than Airport, you will switch to the Ethernet when plugged in, and switch to Airport when ethernet is unplugged.

    You can change the Service Order via the System Preferences -> Network -> Left side Column -> Gear icon -> Set Service Order.
  • BobHarris Level 6 Level 6 (16,415 points)
    Another thought, if staying with DHCP, maybe fill in the System Preferences -> Network -> Advanced -> DHCP Client ID

    Maybe the router will use that name as your DNS name when it assigns you an IP address.

    This is a total wild guess.
  • nerowolfe Level 6 Level 6 (13,065 points)
    One of the Leopard Network options is DHCP with manual address. I think it's worth a try, but I still don't know the whyfor, since it's a recent thing. I have had this modem for several months since I got FIOS, and this is the first time (maybe the second) it's happened.
    It's still not clear to me if the router is simply the result of the problem or causing it.
    I will reboot later, with the Ethernet cable unplugged and AirPort off and see what happens.
    I will look into the router GUI from my other MBP and see what shows up.
  • Bang A. Lore Level 2 Level 2 (180 points)
    nerowolfe wrote:
    I see nothing useful.

    Then you must not know what Bonjour is. Look it up.
  • nerowolfe Level 6 Level 6 (13,065 points)
    Bang A. Lore wrote:
    nerowolfe wrote:
    I see nothing useful.

    Then you must not know what Bonjour is. Look it up.

    I know what BonJour is, so please explain why this issue just happened today, when I have changed nothing on my computer for several months, and how it relates to BonJour?
    Thanks. I appreciate your input.
  • nerowolfe Level 6 Level 6 (13,065 points)
    As an update,

    systemsetup -getcomputername
    returns the correct name, as does

    systemsetup -getlocalsubnetname

    so I still don't really know from where the new-host (n) is coming from and I hope it does not escalate numerically upwards
  • nerowolfe Level 6 Level 6 (13,065 points)
    It was the router
    When I unplugged the Ethernet cable from the box, and closed/reopened terminal, the prompt was correct. As soon as I plugged the Ethernet cable in, the prompt (after closing and restarting terminal) was the wrong one.
    I left the Ethernet Network settings alone, but changed the AirPort Network settings to use DHCP with manual address and used the same IP as the Ethernet connection.
    Without a reboot, everything is back the way is should be.
    Once caveat - I noticed that in the network settings, Configure IPv6 was set to automatic. I turned it off in both Airport and Ethernet. That's for a future time.
Previous 1 2 3 Next