Unusual prompt in the terminal


I have a really unusual prompt in my Unix terminal (I'm using macOS). It looks like this:


I've never seen the @Galaxy-A7-2016 bit before and I'm worried someone might have poked around my computer but it definitely did not happen. Only way could have been remote.

Best Answer

The term is 'prompt'. Usually it consists of username@hostname (the computer's name), so most likely Galaxy-A7-2016 got configured as your computer name in macOS somehow.

Exactly how it appeared there is mostly speculation (it could possibly be discovered from the macOS system logs, but I don't know where the specific logs are located, if they even exist). But my first guess is that it was obtained through DHCP from a buggy router, because DHCP-provided hostnames are a somewhat common source of confusion on macOS systems:

  1. Router doesn't have anything yet
  2. The "Galaxy A7" phone connects to Wi-Fi and sends a DHCP lease request, adding "my hostname = Galaxy-A7-2016" among the DHCP options.
  3. Router issues a new address lease and remembers the provided hostname. (Many home routers store these hostnames so that they could be shown in a "Connected devices" list or similar.)
  4. Sometime later, your macOS computer connects to the same network and sends a DHCP lease request.
  5. Router tries to find an existing lease and somehow selects the lease previously used by the phone.
  6. Router issues the address lease, including the hostname it has previously remembered ("your hostname = Galaxy-A7-2016" among the DHCP options).
  7. macOS automatically changes its hostname to that provided by DHCP.

I have no idea how step 5 would happen, but nevertheless this is the least unlikely option that I could think of.