1

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

  • Is your terminal running on an Android phone? I guess this is the hostname. – Thomas Weinbrenner Oct 13 '15 at 19:40
  • No Im running it on my mac. – Daniel Jacobson Oct 13 '15 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 '15 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 '15 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. – Mark Plotnick Oct 13 '15 at 21:09
5

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.