Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Suddenly, this morning, I open a Terminal window and I get this:

I have no name!@macbook:~$ whoami
502

** I am not a number! I am a human being! **

What gives? Anyone know what I need to do to get my name back?

I suppose there are two problems here, one is that my hostname is undefined, the other is that whoami reports my name as a number.

share|improve this question
2  
BTW -- for those interested, i logged out (command-shift-Q) and after logging back in and restarting terminal, the problem is gone! Still interested in what may have caused this, if for no other reason than to advance the state of my McKnowledge. –  ipd Mar 16 '12 at 18:16
    
Are you asking why the computer host name is displayed in the prompt or are you asking why the computer is named “I have no name!”? –  Chris Page Mar 17 '12 at 1:58
    
I am asking why, suddenly, my bash prompt displays "I have no name!" rather than a hostname. Perhaps its just a coincidence that whoami is also reporting my number rather than my name. –  ipd Mar 19 '12 at 18:59
1  
What do hostname and id -p return? –  CajunLuke Mar 19 '12 at 19:33
    
my system has returned to normal. Good suggestion though, if it happens again i'll check them both! –  ipd Mar 20 '12 at 18:03

7 Answers 7

up vote 8 down vote accepted

Something in memory got corrupted, and the mapping between your userID (502) and your username (ipd) was lost. I've seen it happen (usually when I've manually killed hung system processes), although I'm not sure exactly what causes it. launchd maybe?

Because that mapping is lost, whoami can't convert your ID into a username so returns the ID, and your prompt defaults to the "I have no name!" message because you effectively don't have a name.

Logging out and back in might fixit, but restarting is the best way (as you discovered).

Basically, it's a symptom of another problem, and not a problem in and of itself.

share|improve this answer
    
Best theory i've heard yet, thanks! –  ipd Mar 26 '12 at 23:19
1  
I wish I could explain just how that mapping gets lost, but I've never dug deep enough to figure it out. –  Bobson Mar 27 '12 at 16:16
    
This just happened to me again. I had killed launchd, and I was now 501, which prevented me from using sudo. I still don't know whether launchd will restart itself, or what else not having it running will affect. –  Bobson Sep 23 '12 at 3:42

I see it's an old thread, but here is the solution to this problem (without restarting the whole computer).

The problem is in the opendirectoryd daemon and the earliest reports date from the beginning of 2011. Restarting the daemon (switching users with an admin one via Fast User Switching) fixes the problem.

While writing this answer, I've found a similar question in the Serverfault here, which also covers my answer.

share|improve this answer

This happens to me randomly when I resume from standby (ie opening my laptop). A log out or reboot is the only way for me to fix it. I dont know exactly what causes it. As I type it is happening right now. As the comment in the original post asked, I ran id -p and it crashed. (Crash report: http://pastebin.com/nmFFQELq)

Console commands: whoami - returns 501

id -p - crashes

cat /etc/passwd - my user is not in the document.

any ssh attempt fails with the error: You don't exist, go away!

I also checked out the console, from waking up, a bunch of random "Socket not connected" errors appear (which I think might be normal, being that wireless doesnt connect immediately) from programs like dropbox. An interesting error appears though:

4/12/12 8:37:09.045 PM coreservicesd: _scserver_ServerCheckin: client uid validation failure; getpwuid(501) == NULL

4/12/12 8:37:09.400 PM coreservicesd: _scserver_ServerCheckin: client uid validation failure; getpwuid(501) == NULL

Still not sure what is causing it, but thought I would share these diagnostics.

Im on a Mid 2009 MacBook Pro with 10.7.3 installed

share|improve this answer

See if the permissions of the file /etc/passwd are set up like this:

-rwxr--r--

because it reads the user name from the passwd file.

share|improve this answer

I solved the problem by using iterm=>preferences=>URL_handler and connecting whoami to my username .. after restart on iterm, problem was no more

share|improve this answer

I had this same baffling problem today (Lion 10.7.5) and dscacheutil -flushcache fixed it for me, as suggested in a comment in some blog.

share|improve this answer

Go to the home folder in Terminal and run . ~/.bashrc.

It works!!

share|improve this answer
3  
I don't think re-sourcing .bashrc solves the problem here... –  patrix Oct 23 '12 at 7:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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