The groupmems
command is used to manage the membership of a user’s major groups. This command is particularly useful for system administrators who need to manage the group membership of many users at once. With groupmems
, you can easily add or remove users from a group, or display the members of a group.
Overview
The basic syntax for the groupmems
command is as follows:
groupmems [options] groupname
Here, groupname
is the name of the group you want to manage. The available options for this command are listed below.
Adding Users to a Group
To add users to a group, use the -a
option followed by a comma-separated list of usernames. For example, to add users user1
and user2
to the group mygroup
, you would use the following command:
groupmems -a user1,user2 mygroup
Removing Users from a Group
To remove users from a group, use the -d
option followed by a comma-separated list of usernames. For example, to remove users user1
and user2
from the group mygroup
, you would use the following command:
groupmems -d user1,user2 mygroup
Displaying Group Members
To display the members of a group, use the -l
option. For example, to display the members of the group mygroup
, you would use the following command:
groupmems -l mygroup
Options
The available options for the groupmems
command are listed below:
Option | Description |
---|---|
-a |
Add users to the group |
-d |
Remove users from the group |
-l |
List the members of the group |
-h |
Display help message |
-V |
Display version information |
Troubleshooting tips
If you encounter issues with the groupmems
command, here are some troubleshooting tips:
- Make sure you have the necessary permissions to manage group membership.
- Check that the group and user names are spelled correctly.
- Verify that the group exists before attempting to add or remove users.
Notes
- Only users with root or sudo privileges can use the
groupmems
command. - The
groupmems
command only manages a user’s major groups, not their supplementary groups.