[Cialug] 'whoami' versus 'who am i', or Identity crisis in Linux-Land

David Champion dchampion at visionary.com
Mon Jul 21 16:06:35 CDT 2008


 From the who man page (and --help) on my Mandriva system:

"If ARG1 ARG2 given, -m presumed: `am i' or `mom likes' are usual."

-dc

Jeff Chapin wrote:
> So, in the course of my job, I stumbled across this little nugget of a 
> command that is powerful, useful, and humorous.
>
> Where I work, we have an environment where log in to the server as one 
> user (ourselves) and `sudo su - xxx` to another user to do certain 
> tasks, such as update and runs scripts. When we do a CVS checkout, it 
> is as our own user, with our user name and our passwords.
>
> The issue is that the command 'whoami' returns the name of the user 
> currently running code -- not the user you logged in as. The command 
> 'who am i' will tell you who you origninally logged in as.  'who' 
> tells you all the users logged in. 'who i'. 'who a', etc, etc, return 
> nothing that I have discovered. It appears that the only options that 
> don't require a '-' are 'am i' -- typed exactly like that, and this is 
> not in the man page. Incidentally, 'who -a -m -i' actually gives 
> different output.
>
> I have no idea why I get such a kick out of this command, other than 
> the fact that it looks like it should not be a real command.
>
> And, to come full circle, we added the following to our documentation 
> to simplify our documentation and make things as streamlined as possible:
> export CVSROOT=$(who am i | awk '{print 
> $1}')@cvs.server.example.com:/cvsroot;
> Now, no matter who logs in to do the updates, you run the same 
> commands and let the computer do the work of figuring out what user 
> should be used for CVS.
>
>
>
> Jeff Chapin
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
>




More information about the Cialug mailing list