Linux Groups Command and Examples

This post will guide you how to use the Linux groups command to print the groups a user belongs to. How do I display the groups a user is in on Linux system.

Linux groups Command


Syntax:

groups [OPTION] ... [USERNAME]

Description

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).

Linux groups command Examples


The groups command is very easy to use in Linux, you just need to pass the username to it as one argument.

Type:

#groups adm

outputs:

[root@os_x8664 ~]# groups adm
adm : adm

Get more information about groups command


If you want to get more information about groups command in Linux, you can run the groups command with –help or –version option.

Type:

# groups --help

Outputs:

[root@ol7_x8664 ~]# 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: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'groups invocation'

Or

# groups --version

Outputs:

[root@ol7_x8664 ~]# groups --version
groups (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie and James Youngman.

 

You might also like:

Sidebar



back to top