Unknown user in terminal

Im having a strange problem with the terminal in OS X.

When I open the terminal the username at the command prompt is:

unknown-04-0c-ce-e3-0d-c2: ~

I can't pinpoint when this first started or why unfortunately. I usually use iTerm for web development purposes but this also occurs in the normal OS X Terminal app.

Any ideas/help would be really appreciated.

Thanks

Update: Thanks to @fayadfami and @aliasgar for the correct answers and steering me in the right direction. Also this forum post helped http://forums.macrumors.com/showthread.php?t=152407 The extract from the right post:

Having run into the exact same issue myself, and having come across this thread while attempting to figure it out, I thought I'd post the answer.

OS X is initially setting your hostname to what's set for your Computer Name in Sharing; however, if you're set up for DHCP and you match a current lease on your DHCP server (i.e., match the IP address of another recent user), OS X will then set your hostname to whatever the DHCP server currently has for that lease.

This freaked me out incredibly at first, as I had just reformatted (having just purchased my first Mac and wanting to see how the installer worked) and knew I had not yet changed the Computer Name in Sharing -- yet my system hostname at the Terminal prompt was indeed changed to what I had previously set, pre-format. I grepped around, not finding the name anywhere save log entries; I thought either the format didn't actually properly wipe everything, or I was losing my mind. Finally I logged into my router (it's a Linksys WRT54GS running OpenWRT), and found the hostname in the current leases file. I then manually set my Mac's IP to something different, and voila! -- the hostname was back to what I expected.

I hope this helps save someone from the same paranoia I went through.


Solution 1:

  • What you see at the prompt at the terminal is a name assigned by your DHCP Server appended by your MAC Address

  • The name of your Macintosh has been changed accidentally, or some program / app has changed it explicitly (or may NOT have a name in your case).

  • Go to System Preferences and click on Sharing. Change the Computer Name. I am attaching the screenshot of the same.

Change mac name

  • Once you do that Reboot you Mac. A standard name may look like "Steve Jobs' MacBook." Just personalize this with your own name. And at the prompt it would appear like Steve-Jobs-MacBook-Pro:~ steve$

Solution 2:

A really simple way to sort this out is to simply go to System Preferences > Network > Advanced > TCP/IP, and simply make up any old name for the DHCP client ID (below the 'Renew DHCP Lease' button).

Solution 3:

There is a great article on how to customize your Terminal prompt over at OSX Daily. Not sure exactly why yours has changed, but customizing it will get you back to normal... or something different if you fancy it :)

I'll quote some of the article below:

The default command line prompt in Mac OS X is something like: ComputerName:CurrentDirectory User$ or MacBook:~/Desktop Admin$

Kind of boring and not the best, right? It’s quite easy to change. We’re going to assume you use the default bash shell, so you’ll be editing either the file .bashrc by default, or .profile if you installed fink. At the Terminal prompt, type: nano .bashrc

Now type: export PS1=" "

Between the quotation marks, you can add the following lines to customize your Terminal prompt:

  • \d – Current date
  • \t – Current time
  • \h – Host name
  • \# – Command number
  • \u – User name
  • \W – Current working directory (ie: Desktop/)
  • \w – Current working directory, full path (ie: /Users/Admin/Desktop)

So, let’s say you want your Terminal prompt to display the User, followed by the hostname, followed by the directory, the .bashrc entry would be:

export PS1="\u@\h\w$ "

which will look like: Admin@MacBook~Desktop/$ "