【Amazon GWスマイルセール開催中】4/18(金) 9:00 ~ 4/21(月) 23:59まで限定!バッファローのWi-Fiルーターやスイッチングハブ、Xiaomiスマートウォッチ・タブレット・モニター、iPhone SE整備済み品など多数アイテムが最大19%OFF!

How to Use the Windows whoami Command | Check Logged-In User Information

目次

What is the whoami Command?

The whoami command in Windows displays the name and security information of the currently logged-in user. When executed, it shows the username and domain details, helping you quickly identify which account is being used on the system. This is especially useful for managing multiple accounts or checking administrative privileges.

Main Uses

  • Check the current username: Easily view the username and domain information of the logged-in account.
  • Verify user privileges: Determine whether the current user belongs to certain security groups or has specific privileges.
  • Retrieve user information in scripts: Automatically obtain user details within batch scripts or system processes.

How to Use the whoami Command

https://twitter.com/tama_global/status/1848522941706997989

Running the whoami command displays the current logged-in username. You can also use additional options to display more detailed information.

Basic Syntax

whoami

This command outputs the name of the current user account.

Examples

  1. Display the current username
whoami

This command shows the username of the currently logged-in user in the format username\domain.

  1. Display detailed information
whoami /all

This command provides detailed information about the current user, including group memberships, privileges, and the security identifier (SID). It’s useful for checking security or permission details.

Options for the whoami Command

1. /all Option

whoami /all

Displays all available information about the current user, including user ID, group memberships, privileges, and security details. If the user is part of multiple security groups, all related details are shown.

2. /user Option

whoami /user

Displays the username along with the Security Identifier (SID), which is a unique identifier for the user.

3. /groups Option

whoami /groups

Lists all groups the current user belongs to, including security and local groups. This is helpful for checking permissions or group memberships.

4. /priv Option

whoami /priv

Shows a list of privileges assigned to the current user. This helps verify what administrative or special permissions the user has.

Practical Use Cases for whoami

1. Check User Information in a Script

@echo off
echo Currently logged-in user: %USERNAME%
whoami /user

In this script, the whoami command is used to display the currently logged-in user’s information, including the SID. It’s useful for system management and security checks within automation scripts.

2. Verify Administrative Privileges

whoami /priv

This command shows the current user’s privileges, allowing you to confirm if the user has administrative rights.

Important Considerations When Using the whoami Command

  • Administrator privileges: To view detailed user information (especially with the /priv option), you may need to run the command with administrator privileges.
  • Domain vs. local users: The output of the whoami command can differ between domain users and local users, so ensure you understand the network environment when checking user details.

Related commands

Conclusion

The whoami command is a convenient tool for quickly checking the currently logged-in user and associated security information in Windows. By verifying the user’s privileges, group memberships, and SID, you can efficiently manage system settings and troubleshoot issues. This command is especially useful in environments where multiple accounts or security groups are used.

Tamaglo

最後までお読みいただきありがとうございます。

執筆者:玉城 学(タマキ マナブ)

IT業界歴10年以上。ヘルプデスク・サーバーエンジニアとしてWindowsの設定、クラウド管理、PC最適化を担当。

現在はPC設定・Office活用の専門家として、ブログやYouTubeで情報を発信中。

詳しいプロフィールはこちら

SNSでも情報を発信しています: YouTubeTikTokInstagram

Comments

To comment


The reCAPTCHA verification period has expired. Please reload the page.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here

目次