2

This is what is looks like when I open a new terminal. Im not sure what the text before the ~ user$ is supposed to mean but it seems really weird that is says android-some_alphanumeric_id.
enter image description here

8
  • Is your terminal running on an Android phone? I guess this is the hostname.
    – user90883
    Oct 13, 2015 at 19:40
  • No Im running it on my mac. Oct 13, 2015 at 19:41
  • 3
    That's probably your host name for some reason. What does hostname print out? Or it could be your user name; check with id. Finally, if it's not one of them, the output of declare -p PS1 please.
    – derobert
    Oct 13, 2015 at 20:03
  • The text before the username means the machine's current hostname. It should match the output of the hostname command, or the contents of /etc/hostname.
    – snetch
    Oct 13, 2015 at 20:30
  • 2
    Sounds like your network administrator either mixed up some address pools on the DHCP server, or has a sly sense of humor. Oct 13, 2015 at 21:09

1 Answer 1

6

By default, the prompt you see when opening a terminal is defined by the variable $PS1, which usually contains:

$ echo $PS1
\h:\W \u\$ 

Where \h is the host name.

A DHCP server can assign a host name to a machine connecting to its network (e.g. "managed" by that server): https://askubuntu.com/a/239446/77137

So basically when you connected to that network, your host name was (temporarily) changed to android-that_alphanumeric_id. Although your local configuration is stored in /Library/Preferences/SystemConfiguration/preferences.plist (not to be edited manually) and shouldn't be affected. On a Mac you can check with:

grep -A1 LocalHostName /Library/Preferences/SystemConfiguration/preferences.plist

I got a very similar host name yesterday while connected over Wi-Fi to a university campus network. Once disconnected, my Mac got his normal/local host name back – verified before and after disconnecting by running hostname on the command line.
It might be some commercial DHCP server (popular with in academic environments, apparently) that uses that as the default naming convention for hosts joining the network.

You must log in to answer this question.

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