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.

[root@localhost ~]# groupmems -g grptest -a crybit
[root@localhost ~]# groupmems -g grptest -a crybit 
groupmems: user 'crybit' is already a member of 'grptest'
[root@localhost ~]# 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.

[root@localhost ~]# groupmems -g grptest -d crybit
[root@localhost ~]# groupmems -g grptest -d crybit
groupmems: user 'crybit' is not a member of 'grptest'
[root@localhost ~]# 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:

[root@localhost ~]# groupmems -g grptest -a me
[root@localhost ~]# groupmems -g grptest -a crybit
[root@localhost ~]# groupmems -g grptest -l
me  crybit

5, -p, –purge

Purge all users from the group membership list.
Example:

[root@localhost ~]# groupmems -g grptest -l
me  crybit 
[root@localhost ~]# groupmems -g grptest -p
[root@localhost ~]# groupmems -g grptest -l

Its simple, right? 🙂

groupdel, groupadd, groupmod,

Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!