Is there a Windows equivalent of Unix "whoami" command? If so, what is it?
Since Windows 2000, the
whoami command has been part of the standard command line (thanks to pk for clearing that up in comments!).
You can do this: Open a command prompt and type "set" then hit enter. This shows active environment variables. Current logged on username is stored in the USERNAME env variable and your domain is stored in the USERDOMAIN variable.
To piggy-back off the other answers, from a cmd line:
will get you the complete logged on user in domain\username format.
You can do the same thing with Powershell with this:
This reports most of the same information that everyone else is saying but you can also just type
It will return any environment variables that start with U.
As an aside, SET L can be handy for debugging logonserver problems.
From command line? "echo %username%" should do it. The logged in user is stored in the environmental variable "username".
From a graphical session, ctrl-alt-del will give you a screen with the logged in user displayed.
The above are native to the OS and better answers, but in the spirit of completeness, there's literally a whoami.exe in the 2000 & XP support tools. At 32 kb, it'd be easy to roll out through group policy, if you had your heart set on that command.
In the autoexec, or at a DOS prompt, type prompt %USERDOMAIN%\%USERNAME% $p$g, and you will display who you are logged in as, and see the typical prompt like this: DOMAIM\username C:>