Who, whoami, and “who am i”

whowhoami

I can understand the commands who and whoami, but what exactly happens when I type:

who am i

and

who am

I am on Ubuntu, nothing happens after them!

Why doesn't Linux / UNIX reply with an error message (something on the line of "unknown arguments" for who), or just reply with the output of who?

Best Answer

If whoami doesn’t output anything, it probably indicates that your shell isn’t a login shell. There’s no user associated with who’s standard input, so who doesn’t output anything — that’s not an error as far as it’s concerned, so it doesn’t output an error message.

If you run

xterm -ls

to open a terminal with a login shell, you should find that whoami and who am i work fine. The same goes for a remote login using e.g. SSH.

Related Question