> For the complete documentation index, see [llms.txt](https://linux-tutorial-cli.gitbook.io/linux-cli-tutorial/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://linux-tutorial-cli.gitbook.io/linux-cli-tutorial/txt-files/groups.md).

# groups

## groups

The `groups` command in Linux is used to list the groups that a user belongs to. It is a very useful command for understanding the permissions that a user has on a system.

The `groups` command takes the following arguments:

* `username`: The username to list the groups for.
* `options`: Optional arguments that control the behavior of `groups`.

The following are some of the most common options for the `groups` command:

* `-a`: Lists all of the groups that the user belongs to, including secondary groups.
* `-g`: Lists the primary group of the user.
* `-h`: Displays the output in human-readable format.

For example, the following command will list all of the groups that the current user belongs to:

```
groups
```

The `groups` command is a very useful command for understanding the permissions that a user has on a system. It is a valuable tool for anyone who needs to manage users and groups.

Here are some additional things to keep in mind about `groups`:

* The `groups` command must be run as a user who has permission to view the groups that a user belongs to.
* The `groups` command can be used to list the groups for any user on the system.
* The `groups` command can be used to list the primary group of a user.

Here are some examples of how to use `groups`:

* To list all of the groups that the current user belongs to:

```
groups
```

* To list the primary group of the current user:

```
groups -g
```

* To list all of the groups that the user `johndoe` belongs to:

```
groups johndoe
```

* To list all of the groups that the user `johndoe` belongs to, including secondary groups:

```
groups -a johndoe
```

The `groups` command is a powerful and versatile tool that can be used to list the groups that a user belongs to. It is a valuable tool for anyone who needs to manage users and groups.

## help

```
Usage: groups [OPTION]... [USERNAME]...
Print group memberships for each USERNAME or, if no USERNAME is specified, for
the current process (which may differ if the groups database has changed).
      --help     display this help and exit
      --version  output version information and exit
```
