Find out who I was before I had switched users in Linux?

1

$ 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?

chrisaycock

Posted 2011-03-25T19:36:45.340

Reputation: 232

Answers

3

  • 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.

user1686

Posted 2011-03-25T19:36:45.340

Reputation: 283 655

The who am i is exactly what I want. I hadn't realized it returns a different answer from whoami. – chrisaycock – 2011-03-25T20:07:59.150

0

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

Hyppy

Posted 2011-03-25T19:36:45.340

Reputation: 3 636