Groups Command in Linux (original) (raw)

Last Updated : 12 May, 2026

The groups command in Linux is used to display the group memberships of a user. It shows the primary group and all supplementary groups associated with a user account. This command is mainly used for permission verification, access control checks and troubleshooting user-related issues.

Syntax

groups [OPTION]... [USERNAME]...

**Note: If no username is specified, the command displays groups of the current logged-in user.

Options of the`groups`command

1. `--help`

It displays usage information and basic details about the command. Use it when you want to understand the correct syntax or available options.

**Command:

groups --help

**Output:

groups_help

--help

2. `--version`

It Displays the installed version of the groups command. It useful for debugging or verifying the installed core utilities version.

**Command:

groups --version

**Output:

groups_version

--version

Examples and Implementation of groups Command

Here are some common ways to use the 'groups' command to view user group memberships:

Example 1: Viewing Group Memberships of a Specific User

The most common use of the groups command is to check a specific user’s group memberships.

**Syntax:

groups [username]

**Command:

groups demon

**Output:

groups demon

groups demon

Example 2: Display Group Membership of Current User

Here the current user is a demon. So, when we give "groups" command we only get groups in which 'demon' is a user.

**Command:

groups

**Output:

groups

groups

Example 3: Display Group Membership of root User

This example shows how to check the group memberships of the root user account. The root user is the superuser in Linux and typically has full system privileges.

**Command:

groups root

**Output:

groups root

groups root

Example 4: Checking Multiple Users at Once

The groups command allows you to pass multiple usernames in a single execution. This helps administrators verify group memberships of several users quickly without running the command repeatedly.

**Syntax:

groups user1 user2 user3

**Command:

groups captain-levi gulfam gfg0913

**Output:

groups_multiple_user

Checking Multiple Users at Once

Important Note on Primary and Supplementary Groups

newgrp groupname