groupadd — Create a group
Linux / User and Security Management / groupadd.html
Creates a new user group and assigns it a GID.
Basic Information
| Command Name | groupadd |
|---|---|
| One-line Introduction | Creates a new user group and assigns it a GID. |
| Provided by | shadow-utils (passwd on some distributions) |
| Official Documentation | https://man7.org/linux/man-pages/man8/groupadd.8.html |
| Supported Operating Systems | Linux |
| Installation Status | Installed by default |
| Category | Linux security and accounts (tags: Accounts, permissions and audit (tags: groupadd, group, gid, permission)) |
What is this command?
groupadd adds a new entry to /etc/group. Adding members is a separate step (usermod -aG or gpasswd -a); groupadd only creates the group.
Groups grant the same permissions to several accounts at once. Combining purpose-specific groups with directory group ownership and the setgid bit enables shared directories without widening individual permissions.
What problems does it solve?
- Creating a shared group for deployment or operations
- Granting several service accounts access to one directory
- Pinning a GID so multiple hosts stay consistent
- Adding new accounts to an existing permission model
Key features
Creating a group
Specify only a name and the next free GID is assigned.
- When to use: Creating a typical collaboration group
- What you get: A group referenceable by name exists.
- Limitations: Existing names are rejected, so check first.
Fixing the GID
The -g option assigns a specific number.
- When to use: When the same GID must exist on multiple hosts
- What you get: Permissions match on NFS or shared volumes.
- Limitations: Creation fails if the GID is taken.
System groups
The -r option uses the low GID range for services.
- When to use: Creating groups dedicated to daemons
- What you get: Keeps service groups separate from user groups.
- Limitations: Ranges differ by distribution, so do not assume a GID.
Installation and usage
Check whether it is installed
groupadd --help
sudo apt install passwd # Debian/Ubuntu sudo dnf install shadow-utils # Fedora
Real-world examples
Create a regular group
Create a group by name alone.
sudo groupadd deploy
Assign a specific GID
Use the same GID across hosts.
sudo groupadd -g 3000 deploy
Add members
Add accounts to the group as a supplementary group.
sudo usermod -aG deploy alice
getent group deploy