13

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.

3
  • which OS version are you running?
    – JoshP
    Sep 5, 2012 at 22:22
  • @Josh OS X 10.7.4 Sep 6, 2012 at 19:24
  • 1
    On my Mac, switching the WiFi off and back on fixed this for me. Mar 21, 2018 at 23:02

3 Answers 3

6
  • 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$
6
  • Thanks aliasgar but this didn't work for me. My machine name is still the same as it was in the Sharing preferences pane. I tried to change it and reboot but it still say unknown in the terminal. Sep 5, 2012 at 21:41
  • 2
    @GilesB Could it be that your changes are being over written by dhcp name assign? After following @aliasgar's steps and doing a cold reboot look at /var/log/system.log closely on the processes starting up while your system boots and if you can find a process responsible for this.
    – paintbox
    Sep 6, 2012 at 11:46
  • @fayadfami I just looked at the log file and the first line has the same 'unknown...' username in it, the whole line reads: Aug 26 00:30:02 unknown-04-0c-ce-e3-0d-c2 newsyslog[23504]: logfile turned over Sep 6, 2012 at 19:23
  • @fayadfami just spotted this in that log file, any ideas on how to change? Sep 7 00:52:45 Giless-MacBook-Air usbmuxd[58]: _AMDeviceConnectByAddressAndPort (thread 0x100781000): IPv4 Sep 7 00:52:48 unknown-04-0c-ce-e3-0d-c2 configd[16]: setting hostname to "unknown-04-0c-ce-e3-0d-c2.home" Sep 7, 2012 at 9:05
  • 1
    @fayadfami i got it! You were right, the dhcp name assign was changing it to something on the router. Thanks for all your help mate. This forum post helped - forums.macrumors.com/showthread.php?t=152407 Sep 7, 2012 at 9:13
4

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).

0
1

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/$ "

4
  • Thanks Josh but unfortunately this doesn't work for me either. I end up with: unknown-04-0c-ce-e3-0d-c2: ~ \u@\h\w$ → Sep 5, 2012 at 21:45
  • I think i followed a similar article when I originally modified my terminal. Il see if I can find the original, may help. Sep 5, 2012 at 21:47
  • This is the article I followed originally to edit the prompt, I think its definitely an issue with the user as editing the prompt is no problem, it still shows an unknown user - net.tutsplus.com/tutorials/tools-and-tips/… Sep 5, 2012 at 21:57
  • Ack, sorry to hear that... I'll keep looking :)
    – JoshP
    Sep 5, 2012 at 22:23

You must log in to answer this question.

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