The groupmems command’s switches with example – Unix/Linux

The command ‘groupmems’ is used to administrate Linux groups.
Syntax:

# groupmems -a user_name | -d user_name | [-g group_name] | -l | -p

Switches with example:

1, -a, –add user_name

Add an user to the group membership list.
If the /etc/gshadow file exist, and the group has no entry in the /etc/gshadow file, a new entry will be created.

[[email protected] ~]# groupmems -g grptest -a crybit
[[email protected] ~]# groupmems -g grptest -a crybit 
groupmems: user 'crybit' is already a member of 'grptest'
[[email protected] ~]# groupmems -g grptest -a me

2,-d, –delete user_name

Delete a user from the group membership list.
If the /etc/gshadow file exist, the user will be removed from the list of members and administrators of the group.
If the /etc/gshadow file exist, and the group has no entry in the /etc/gshadow file, a new entry will be created.

[[email protected] ~]# groupmems -g grptest -d crybit
[[email protected] ~]# groupmems -g grptest -d crybit
groupmems: user 'crybit' is not a member of 'grptest'
[[email protected] ~]# groupmems -g grptest -d me

3, -g, –group group_name

The superuser can specify which group membership list to modify.

4, -l, –list

List the group membership list.
Example:

[[email protected] ~]# groupmems -g grptest -a me
[[email protected] ~]# groupmems -g grptest -a crybit
[[email protected] ~]# groupmems -g grptest -l
me  crybit

5, -p, –purge

Purge all users from the group membership list.
Example:

[[email protected] ~]# groupmems -g grptest -l
me  crybit 
[[email protected] ~]# groupmems -g grptest -p
[[email protected] ~]# groupmems -g grptest -l

Its simple, right? 🙂

groupdel, groupadd, groupmod,

Post navigation

Arunlal Ashok

Operations Engineer at Endurance International Group. Linux lover. Like to play on Linux console. I started this blog to share and discuss Linux thoughts.

Always happy for an open discussion! Write to arun (@) crybit (dot) com. Check about me for more details. About this blog and our strong members, check The team CryBit.com
We like to travel. Our travelogues are published at Trip Mentor