Linux groups Command: Show a User's Group Memberships

groups shows the names of the groups the current user or a specified user belongs to. It is used to quickly check shared file access permissions or membership in administrative groups.

What is the groups command?

When run without arguments, it prints the list of groups for the current process. If you specify a user, it retrieves the group information for that account. If you need the numeric GID or the distinction between primary and supplementary groups, id provides more detailed information.

Basic syntax

groups [user...]

Installed implementations and options may vary depending on the distribution. Check the description for your system with man groups.

Examples

Check groups in the current session

See if the groups assigned to an account are reflected in the current shell.

groups

Check a specific user

Check which groups the account you are managing belongs to.

groups alice

Compare with numeric ID

When investigating permission issues, check both the group name and ID together.

id alice

Linking Group List to Permissions

groups shows the group names of the current user or a specified user. The output format may vary depending on the implementation and whether arguments are used.

groups alice

Example output:

alice : alice sudo

Here, the first alice is the user being queried, and the list after the colon is the group list. Changes in group membership may not be reflected in sessions that are already running immediately after the change. Check the group IDs actually applied to the current process using id.

Main Options and Format

Options/Format Description
--help Show a simple usage of the GNU implementation.
--version Show the version of the GNU implementation.

Precautions when using

Changes may not be reflected in existing login sessions immediately after a group is newly added. Check groups and id in the current session and log in again if necessary. Just seeing the group name does not mean you have access to all paths. Parent directory permissions and ACLs also affect access.

Frequently Asked Questions

Why are the results of groups alice and groups without arguments different?

The former may query the account database anew, while the latter shows the list of groups that the current process has.

Official Documentation

The exact behavior of options and implementation differences can be checked in the official documentation related to groups.

More in This Category
Linux rpm Command: Inspect RPM Packages and the Installed Database

Linux rpm Command: Inspect RPM Packages and the Installed Database

Learn how to inspect RPM Packages and the Installed Database with the Linux rpm command, including practical examples, key options, and important precautions.

Linux join Command: Combine Files by a Common Field

Linux join Command: Combine Files by a Common Field

Learn how to combine Files by a Common Field with the Linux join command, including practical examples, key options, and important precautions.

Linux shutdown Command: Schedule a Shutdown or Restart

Linux shutdown Command: Schedule a Shutdown or Restart

Learn how to schedule a Shutdown or Restart with the Linux shutdown command, including practical examples, key options, and important precautions.

Linux help Command: Read Help for Bash Built-in Commands

Linux help Command: Read Help for Bash Built-in Commands

Learn how to use the Linux help command to read usage information for Bash built-in commands, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux chown Command: Change File Owner and Group

Linux chown Command: Change File Owner and Group

Learn how to change File Owner and Group with the Linux chown command, including practical examples, key options, and important precautions.

Linux xargs Command: Pass Standard Input as Command Arguments

Linux xargs Command: Pass Standard Input as Command Arguments

Learn how to pass Standard Input as Command Arguments with the Linux xargs command, including practical examples, key options, and important precautions.

Linux curl Command: Make URL Requests and Inspect HTTP Responses

Linux curl Command: Make URL Requests and Inspect HTTP Responses

Learn how to make URL Requests and Inspect HTTP Responses with the Linux curl command, including practical examples, key options, and important precautions.

Linux realpath Command: Resolve Absolute and Canonical Paths

Linux realpath Command: Resolve Absolute and Canonical Paths

Learn how to use the Linux realpath command to resolve relative paths, symbolic links, and redundant path components, with essential options, practical examples, output interpretation, and common troubleshooting tips.

A History of Linux: From a 1991 Hobby Project to Global Infrastructure

A History of Linux: From a 1991 Hobby Project to Global Infrastructure

Trace the history of Linux from Unix and the GNU Project through the first Linux kernel, distributions, enterprise adoption, cloud computing, containers, and modern infrastructure.

Linux diff Command: Compare Text Files and Directories

Linux diff Command: Compare Text Files and Directories

Learn how Linux diff compares text files and directories, produces unified patches, ignores selected whitespace changes, and reports differences through exit status.