What is the Windows equivalent of Unix "whoami" command?

Solution 1:

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:

echo %USERDOMAIN%\%USERNAME%

will get you the complete logged on user in domain\username format.

You can do the same thing with Powershell with this:

write-host $env:userdomain\$env:username

Solution 2:

This reports most of the same information that everyone else is saying but you can also just type

SET U

It will return any environment variables that start with U.

As an aside, SET L can be handy for debugging logonserver problems.