Now in Linux we have two types of groups
- Primary Group
- Secondary Group
View all the members of the primary group
First you need to know the GID of the group of whoose members you want to query for
Syntax:
# grep "group_name" /etc/group
# grep dba /etc/group
dba:x:503:
Now grep that GID to get list of users under dba group
# grep 503 /etc/passwd
deepak:x:501:503::/home/deepak:/bin/bash
user:x:502:503::/home/user:/bin/bash
deep:x:503:503::/home/deep:/bin/bash
View all the members of the secondary group
To do this we have a no. of methods
Method 1
# getent group dba
dba:x:503:deepak,deep,user,user1
Method 2
# grep dba /etc/group
dba:x:503:deepak,deep,user,user1
Method 3
Syntax
# groupmems -g "group_name" -l
# groupmems -g dba -l
deepak deep user user1
Related Articles
How to create password less ssh connection for multiple non-root users
How to create user without useradd command in Linux
How to give normal user root privileges using sudo in Linux/Unix
How to give permission to user to run some commands in Linux