Once sudo su would certainly to root, exists a command to see my username?

I have sudo civil liberties on a redhat box ; once I've sudo su - to come to be origin in a shell, exist any kind of commands I can go to see what username I su would certainly FROM?

2019-05-18 23:38:39
Source Share
Answers: 2

The shell is parent procedure is su, so you require to figure out the customer running su is parent procedure:

ps -o user= $(ps -o ppid= $PPID)

But you should not be doing sudo su - if your variation of sudo is not also old to have sudo -i. Sudo establishes the setting variable SUDO_USER to the name of the customer that ran sudo. You will not see it with sudo su - due to the fact that su - rubs the setting.

$ sudo -i
# echo $SUDO_USER
2019-05-21 10:18:46

Run command whoami it will certainly return you something like that:

gladimdim tty2        2011-01-27 23:54 (:0)

In vibrant "gladimdim" is the customer which was originally logged to system.

2019-05-21 08:58:52