Managing user groups in Linux involves creating, modifying, and deleting groups to control user permissions and access. Here are some common commands used for group management:
1. Create a New Group
To create a new group, use the groupadd command:
sudo groupadd groupname
2. Add a User to a Group
To add a user to an existing group, use the usermod command with the -aG option:
sudo usermod -aG groupname username
3. Remove a User from a Group
To remove a user from a group, you can use the gpasswd command:
sudo gpasswd -d username groupname
4. Delete a Group
To delete a group, use the groupdel command:
sudo groupdel groupname
5. View Group Information
To view the groups a user belongs to, use:
groups username
Example:
To create a group named developers and add a user alice to it:
sudo groupadd developers
sudo usermod -aG developers alice
These commands help you effectively manage user groups and their permissions. If you need more details or examples, let me know!
