Skip to content

Windows WHOAMI command

The Windows whoami command is used to display the username and group information for the current user. It can also show the privileges of the user, such as being a member of the administrators group. This command is useful for troubleshooting and verifying the user account details within a Windows environment. You can run the whoami command in the command prompt to quickly access this information.

WHOAMI Syntax:

Terminal window
whoami [/USER] [/GROUPS] [/PRIV]

Options:

OptionDescription
/USERDisplays the current username.
/GROUPSDisplays the groups a user is a member of.
/PRIVDisplays the privileges of the current user.

Parameters:

There are no parameters for the whoami command.

WHOAMI Usage:

Display Current User

Terminal window
whoami

Displays the username and group information for the current user.

Verify User Privileges

Terminal window
whoami /priv

Displays the current user’s security privileges, such as enabled and disabled privileges.

Output User and Group Information

Terminal window
whoami /all

Displays detailed information about the current user, including user name, group memberships, and security identifiers.

Check User and Group Information in JSON format

Terminal window
whoami /fo json

Displays user and group information in JSON format, suitable for parsing and scripting purposes.

How do I use whoami in Windows?

To use the whoami command in Windows, execute the following command:

Terminal window
whoami

What is the purpose of the /UPN parameter in whoami?

The /UPN parameter in whoami displays the current User Principal Name (UPN) in the output. Here is an example of using it:

Terminal window
whoami /UPN

How can I display the current privileges with whoami?

You can display the current privileges using the /PRIV parameter in whoami. Simply execute the command shown below:

Terminal window
whoami /PRIV

How do I check group memberships with whoami?

To check group memberships in Windows using whoami, use the /GROUPS parameter. Here is the command example:

Terminal window
whoami /GROUPS

Can I get the SID (Security Identifier) using whoami?

Yes, you can retrieve the SID (Security Identifier) for the current user by using the /SID parameter with whoami. Run the following command:

Terminal window
whoami /SID

How do I display the logon ID with whoami?

To display the logon ID, you can use the /LOGONID parameter with the whoami command. Here is how to do it:

Terminal window
whoami /LOGONID

What is the /USER parameter used for in the whoami command?

The /USER parameter in whoami displays the current username. To see the username, execute the following command:

Terminal window
whoami /USER

Applications of the WHOAMI Command

  • Verifying the current user’s identity
  • Checking group membership
  • Scripting and automation tasks
  • Troubleshooting and diagnosing user permission issues