As you might have guessed by now, you can use the addgroup command to add a new group to the Ubuntu system:
sudo addgroup sales
This command creates the new group, sales, and automatically assigns the next available group ID value to it. To add users to the group, use the adduser command, shown in the previous section.
Finally, to remove a group, there's the delgroup command: sudo delgroup sales
This command removes the group from the system, but any files or folders that you assign group privileges to will retain the group ID value.
If a group is set as the primary group for an existing user account, Ubuntu will prevent you from deleting it. If you want to ensure that you delete empty groups only, you can add the --only-if-empty parameter to the delgroup command. If any users belong to the group, Ubuntu will prevent you from deleting the group.
Was this article helpful?