Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
$ whoami
a

$ su b
Password: ...

$ whoami
b

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

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted
  • 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.

share|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
add comment

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

share|improve this answer
add comment

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.