$ whoami

$ su b
Password: ...

$ whoami

Is there a whowasi command? Some way to find out that I was user a before I had become user b?

  • Technically, you didn't switch users; you opened a separate shell process as b. You can suspend it with suspend, use whoami, then return with fg.

  • You can check the owner of the parent process with ps -f $PPID.

  • Use who -m or who am i to see the user you originally logged in as. (This is different from the above two methods because it always returns the same user despite how many times you run su.)

  • Use ps -f to see all processes running on the current tty, including their owners.

| improve this answer | |
  • The who am i is exactly what I want. I hadn't realized it returns a different answer from whoami. – chrisaycock Mar 25 '11 at 20:07

You can do a who to see what user is the original owner of the session

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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