groupadd—This command creates and adds a new group.
groupdel—This command removes an existing group.
groupmod—This command creates a group name or GIDs but doesn't add or delete members from a group.
gpasswd—This command creates a group password. Every group can have a group password and an administrator. Use the -A argument to assign a user as group administrator.
useradd -G—The -G argument adds a user to a group during the initial user creation. (More arguments are used to create a user.)
usermod -G—This command allows you to add a user to a group so long as the user is not logged in at the time.
grpck—A command for checking the /etc/group file for typos.
As an example, there is a DVD-RW device (/dev/scd0) on our computer that the sysadmin wants a regular user named john to have access to. To grant john that access, we would follow these steps:
1. | Add a new group with the groupadd command: # groupadd dvdrw |
2. | Change the group ownership of the device to the new group with the chgrp command: # chgrp dvdrw /dev/scd0 |
3. | Add the approved user to the group with the usermod command: # usermod -G dvdrw john |
4. | Make user john the group administrator with the gpasswd command so that she can add new users to the group: # gpasswd -A john |