Sunday, December 20, 2009

Unix - whoami and who am i

In many unix books most of us have read these words or commands whoami and who am i..These commands are useful when you work in an environment where people have different login ids and you are using sudo access or are first logging thorugh a different name and then switching to another user.
suppose i login with username joe and then i use su - to switch to user pam. Now if i will use the command
joe gid() uid()
$su - pam
password: *******
pam gid() uid() i will use whoami

ok and now i use who am i

$who am i

So you see the difference. its very clear from the example.
Sometimes you might see many screens open, but you really don't know who had initially logged into the system . At that time these commands are very handy.

No comments:

Post a Comment