47

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.

9
  • 4
    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
    Commented Mar 16, 2012 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
    Commented Mar 17, 2012 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
    Commented Mar 19, 2012 at 18:59
  • 1
    What do hostname and id -p return?
    – Cajunluke
    Commented Mar 19, 2012 at 19:33
  • my system has returned to normal. Good suggestion though, if it happens again i'll check them both!
    – ipd
    Commented Mar 20, 2012 at 18:03

10 Answers 10

32

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.

4
  • 1
    I wish I could explain just how that mapping gets lost, but I've never dug deep enough to figure it out.
    – Bobson
    Commented Mar 27, 2012 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
    Commented Sep 23, 2012 at 3:42
  • For what its worth, I just ran into this on a Linux machine, so I would guess the root cause is something in bash. strings /bin/bash | grep "I have" Commented Dec 16, 2015 at 20:03
  • This also happens on sandboxes, where it is common to not have whoami or even its dependencies, try which whoami to see where it is, in my case I did ldd /usr/bin/whoami to find dependencies, see if you have them and or if they are damaged. Commented Jan 12, 2019 at 1:47
13

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.

1
  • This didn't work for me. My symptoms are perhaps a wee bit different. I have a number of terminal windows open, and every existing terminal window has lost its username mapping, but every new window seems to have it without problems. Killing (aka restarting) opendirectoryd did not help. In the "failed" terminals, I also am missing group mapping for com.apple.sharepoint.group.2 and access_bpf, but not groups listed in /etc/group. Seems to me that old terminal processes (and who knows what else) have lost access to opendirectoryd, not that opendirectoryd itself has failed.
    – ghoti
    Commented Sep 8, 2017 at 2:47
3

This happens to me randomly when I resume from standby (i.e. opening my laptop). A log out or reboot is the only way for me to fix it. I don’t 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 doesn’t 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.

I’m on a Mid 2009 MacBook Pro with 10.7.3 installed.

2

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.

1
  • It was 644, not 744. Setting to 744 did not help.
    – Dan
    Commented Nov 29, 2016 at 8:56
1

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.

0

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

0

Make sure your /etc/passwd file permissions are 644

chmod 644 /etc/passwd

After changing permissions , logout and log back in

1
  • It’s interesting that other answers say 644 / 744 permissions are not relevant or complete to solve this. Is there a reference for what the proper permission s should be and when to deviate from them?
    – bmike
    Commented Mar 28, 2021 at 12:44
-1

My problem is the permission in passwd archive, The old permission is -rw------- 1 root root 1280 Jun 9 15:41 passwd I used the command "chmod a+r /etc/passwd" and now all users can read this archive. -rw-r--r-- 1 root root 1280 Jun 9 15:41 passwd Logout the user and try. =)

0
-1

I had this weird issue on my ubuntu when I created a new user

I reviewed the /etc/passwd file

`cat /etc/passwd`

I saw my record had the following details -

`ajit:x:1002:1002::/home/ajitp:/bin/sh`

I changed it as follows -

`ajit:x:1002:1002::/home/ajitp:/bin/bash`
1
-2

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

It works!!

1
  • 6
    I don't think re-sourcing .bashrc solves the problem here...
    – nohillside
    Commented Oct 23, 2012 at 7:56

You must log in to answer this question.

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