Create a Group in Kali Linux
Applies to Kali and most Linux distributions. Requires administrative privileges.
Command Syntax
sudo groupadd [OPTIONS] <group_name>
- sudo — run with administrative privileges.
- <group_name> — the name of the new group.
Examples
1) Create a basic group
sudo groupadd students
2) Create a group with a specific GID
sudo groupadd -g 1050 developers
This creates a group named developers with Group ID (GID) 1050.
Verify the Group
getent group students
# or
cat /etc/group | grep students
Add Users to the Group
Add an existing user to a supplementary group
sudo usermod -aG students alice
- -aG means “append to supplementary Groups.”
Check a user’s group memberships
groups alice
id alice
Use Groups with File Permissions
After creating a group and adding users, you can assign group ownership to files or directories:
# change group ownership
sudo chgrp students /srv/lab
# change owner and group together
sudo chown alice:students /srv/lab
# make directory group-writable and setgid so new files inherit the group
sudo chmod 2775 /srv/lab
Why groups? Groups let multiple users share access to the same resources securely. Combine groupadd, usermod -aG, chgrp/chown, and chmod to control collaborative access.
Troubleshooting & Notes
- Permission denied? Prepend commands with sudo or run as root.
- Group already exists: You’ll see groupadd: group 'X' already exists. Choose a different name or use that existing group.
- Membership not reflected immediately: Log out and back in (or restart your shell session) so your new group membership is applied to your processes.