Tuesday, November 19, 2013

whoami vs who am i

ok this is like Linux 101:
[root@osb-vagrant ~]# who am i
root     pts/1        2013-11-19 11:01 (10.0.2.2)
[root@osb-vagrant ~]# whoami
root
[root@osb-vagrant ~]# sudo -u soa whoami
soa
[root@osb-vagrant ~]# sudo -u soa who am i
root     pts/1        2013-11-19 11:01 (10.0.2.2)


So if you allow some user to sudo a command, and you want to log who that user is, you should use "who am i" and not "whoami".

No comments: