Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To see groups attached to your current session, check its effective security token—not just a directory account record. On Windows, run whoami /groups. On Linux or Unix, run id -Gn for group names or id -G for numeric IDs. These commands report the groups available to the current process, which can differ from directory membership if the session has not refreshed.

Check your current groups from the command line

Windows

Open Command Prompt or PowerShell and run:

whoami /groups

The command lists the groups in the current Windows logon token. Microsoft describes whoami as showing information about the logged-on account’s user, groups, and privileges. To include additional token details, run:

whoami /all

The expanded output includes the current user, group SIDs, privileges, and other access-token information. Group names and SIDs are useful for different checks: names are easier to recognize, while SIDs identify the security principals represented in the token.

Linux and Unix

Run these commands without a username to inspect the current process:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • id -Gn prints group names.
  • id -G prints numeric group IDs.
  • groups prints group names and is equivalent to id -Gn.

The GNU Coreutils groups manual says that, without a username argument, groups reports the primary and supplementary groups for the current process. The GNU Coreutils id manual documents id‘s name and numeric output options.

Which method should you use?

Environment Method What it reports Identity being checked Source
Windows whoami /groups Groups in the current access token Current logged-on identity and token Microsoft Learn
Windows whoami /all Groups plus user, SIDs, privileges, and other token details Current logged-on identity and token Microsoft Learn
Linux or Unix id -Gn or groups Group names Current process when no user is specified GNU Coreutils id manual; GNU Coreutils groups manual
Linux or Unix id -G Numeric group IDs Current process when no user is specified GNU Coreutils id manual

Why the result may not show a recent membership change

These commands inspect the groups carried by the running process or its security token. They do not necessarily perform a fresh lookup of directory membership. GNU documents that process group lists are normally inherited from the parent process and are usually unchanged since login. As a result, changing a group database entry may not update a process that is already running.

Windows group SIDs are likewise carried in the access token. If an administrator adds an account to a group, an existing token may not reflect that change until the account receives a refreshed token—for example, after signing in again or renewing the relevant process or session. If the output appears stale, verify it from a newly created session or process after the applicable refresh.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Inspect the current identity in application code

.NET

In .NET, WindowsIdentity.GetCurrent() returns a WindowsIdentity representing the current Windows user. Enumerate its Groups collection to examine the identity references in that token. The overload with a Boolean argument lets code select the impersonating thread identity or the process identity; choose the one that matches the work being authorized.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

See Microsoft’s documentation for WindowsIdentity.GetCurrent and WindowsIdentity.Groups.

Native Win32

For native Windows code, query the current access token with GetTokenInformation using TokenGroups, then enumerate the returned TOKEN_GROUPS array. Microsoft defines GroupCount as the number of group entries; each entry contains a SID and attributes. This is token data, not a live directory query.

Microsoft documents GetTokenInformation and the TOKEN_GROUPS structure.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.