Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a Windows equivalent of Unix "whoami" command? If so, what is it?

share|improve this question
Yes there is and it's also whoami – DeepSpace101 Sep 1 '14 at 20:45
up vote 58 down vote accepted

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:

write-host $env:userdomain\$env:username
share|improve this answer
+1 for the educational aspect, and for including the domain as well as the username – tomjedrz May 19 '09 at 17:15
@squillman How can I make this work when running a command prompt as Sytem user? Cause in that case, there is no environment variable such as %USERDOMAIN% or %USERNAME% – GianT971 Mar 6 '12 at 14:40
@GianT971 Do you mean LocalSystem? There isn't a way for that account since it's not associated with a logged on user. Typically this account is used for services and when a service is running as LocalSystem then it takes on the security context of the service control manager. – squillman Mar 6 '12 at 15:47
Ok. Yes that's what I meant. Maybe with latest versions of PowerShell it is possible, as when running a .NET app invoking Environment.Username under LocalSystem account, the result is "System". But I have not yet taken a good look at PowerShell – GianT971 Mar 6 '12 at 17:00
@GianT971 You could spawn cmd or powershell processes and run scripts, but you won't get an interactive shell. – squillman Mar 6 '12 at 18:23

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.

share|improve this answer
Somtimes you just see tips that have to be shared, those two are great. – Tubs May 20 '09 at 11:00

It depends on your specific OS, but the whoami command is available as part of the Windows 2000 Resource Kit and Windows XP SP2 Support Tools.

share|improve this answer
+1 Also available by default in Vista+ – Oskar Duveborn May 19 '09 at 17:10
aha, i thought i had used whoami on my laptop at home recently, i guess it worked because it was vista. here at work i'm on xp – Kip May 19 '09 at 19:13

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.

share|improve this answer


share|improve this answer

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.

share|improve this answer

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:>

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.