TrumanWong

groups

Prints the name of the group to which the specified user belongs.

Summary

groups [OPTION]... [username]...

The main purpose

  • Print the name of the group to which the specified user belongs.

Options

--help Display help information and exit.
--version Display version information and exit.

Parameters

username (optional): It can be one or more. If not provided, it defaults to the current user.

return value

Returning 0 indicates success, returning a non-zero value indicates failure.

example

Display the groups to which the linux user belongs

[root@localhost ~]# groups linux
linux: linux adm dialout cdrom plugdev lpadmin admin sambashare

Notice

  1. This command is equivalent to id -Gn.
  2. Each user belongs to a group specified in /etc/passwd and other groups specified in /etc/group.
  3. This command is a command in the GNU coreutils package. For related help information, please see man -s 1 groups, info coreutils 'groups invocation'.