I'm trying to see if
id -r will print out the UID or username of the user who logged into the system despite any
sudo's. I'm interested in doing this so I can keep people a little more accountable and to tailor script functioning accordingly (i.e: they issue a sudo on a script and it pulls information from the logged in user's home directory).
SUDO_USER but I don't want to rely on this because it's a variable that can be modified by the user, and it just has the username of the user who issued the most recent sudo (i.e:
sudo -i ; sudo -iu randomUser ; echo $SUDO_USER prints out "root" instead of the actual user).
Nothing in the man pages or that I can find online seems to indicate what the proper use of this command is and the obvious permutations aren't working:
[root@ditirlns03 ~]# id -r id: cannot print only names or real IDs in default format [root@ditirlns03 ~]# id -r jadavis6 id: cannot print only names or real IDs in default format [root@ditirlns03 ~]# id -r root id: cannot print only names or real IDs in default format
At this point, I'm still not sure
id -r is going to print out what I want, mostly because I can't figure out how to get it to print out anything at all.