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 Tutorial / Hard Links vs. Symbolic Links in Linux: Differences and Examples

Linux Tutorial / Hard Links vs. Symbolic Links in Linux: Differences and Examples

Compare hard and symbolic links through inode and path behavior, then create both kinds of link and observe what happens when the original name changes.

Linux command Command: Run Commands While Bypassing Aliases and Functions

Linux command Command: Run Commands While Bypassing Aliases and Functions

Learn how to use the Linux command command to check command availability and bypass shell aliases or functions, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux locate Command: Search Indexed File Paths Quickly

Linux locate Command: Search Indexed File Paths Quickly

Learn how Linux locate searches a filename database, how updatedb affects freshness, how to limit and filter matches, and when find is the better tool.

Linux mkdir Command: Create Directories and Parent Paths

Linux mkdir Command: Create Directories and Parent Paths

Learn how to create directories with Linux mkdir, build missing parent paths, set permissions, understand umask behavior, and verify results in scripts.

Linux ping Command: Test Host Reachability and Round-Trip Time

Linux ping Command: Test Host Reachability and Round-Trip Time

Learn how to test Host Reachability and Round-Trip Time with the Linux ping command, including practical examples, key options, and important precautions.

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.

Linux Tutorial / Linux Terminal and Shell Basics: Command Syntax and Finding Help

Linux Tutorial / Linux Terminal and Shell Basics: Command Syntax and Finding Help

Learn the difference between a terminal and a shell, read command syntax and output, and use Bash help tools through a short hands-on exercise.

Linux printf Command: Print Values with a Defined Format

Linux printf Command: Print Values with a Defined Format

Learn how to print Values with a Defined Format with the Linux printf command, including practical examples, key options, and important precautions.

Linux readlink Command: Inspect Symbolic Link Targets

Linux readlink Command: Inspect Symbolic Link Targets

Learn how to use the Linux readlink command to display symbolic link targets and optionally resolve canonical paths, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux last Command: Review Login and Reboot History

Linux last Command: Review Login and Reboot History

Learn how to use the Linux last command to review user login sessions, system reboots, and shutdown history, with essential options, practical examples, output interpretation, and common troubleshooting tips.