Groups Command in Linux/Unix With Examples | Code Factory

Donate : Link

Medium Blog : Link

Applications : Link

In linux, there can be multiple users(those who use/operate the system), and groups are nothing but the collection of users. Groups make it easy to manage users with the same security and access privileges. A user can be part of different groups.

Important Points:

  • Groups command prints the names of the primary and any supplementary groups for each given username, or the current process if no names are given.
  • If more than one name is given, the name of each user is printed before the list of that user’s groups and the username is separated from the group list by a colon.
~# 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

GNU coreutils online help: <>
Report groups translation bugs to <>
Full documentation at: <>
or available locally via: info '(coreutils) groups invocation'

Example 1: Provided with a user name

~# groups user1
user1 : user1

~# groups user1 root
user1 : user1
root : root

Example 2: No username is passed then this will display group membership for the current user

user1:~$ groups                                                                                                                           

root:~# groups

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s