Administration – Adding Groups
Each new user is assigned to one or more groups. You can create groups at any time and add users to those groups. The permissions that each group has to use files and directories in Linux depend on how the group permission bits are set on each item.
Assigning users to a group allows you to attach ownership to files, directories, and applications so that those users can work together on a project or have common access to resources.
Commands similar to those for working with users are available for managing your groups. You can add groups (groupadd), change group settings (groupmod), delete groups (groupdel), and add and delete members from those groups (groupmems).
Here are some examples for adding new groups with the groupadd command:
Create new group with next available GID
$ sudo groupadd marketing
Create new group with GID of 1701
$ sudo groupadd -g 1701 sales
Create group with existing GID
$ sudo groupadd -o -g 74 mysshd
With the groupmod command, you can change the name or group ID of an existing group. Here are examples:
Modify myadmin to use GID 491
$ sudo groupmod -g 491 myadmin
Change name of myadmin group to myad
$ sudo groupmod -n myad myadmin
To remove an existing group, use the groupdel command. Here is an example:
Remove existing myad group
$ sudo groupdel myad
Keep in mind that removing a group or user doesn’t remove the files, directories, devices, or other items owned by that group or user. If you do a long listing (ls -l) of a file or directory assigned to a user or group that was deleted, the UID or GID of the deleted user or group is displayed.