groupadd
Overview
The groupadd
command creates a new group account on the system. It adds a new group entry to the system account files.
Syntax
groupadd [options] GROUP
Common Options
Option | Description |
---|---|
-f, --force |
Exit successfully if group exists |
-g, --gid GID |
Use specific GID |
-K, --key KEY=VALUE |
Override /etc/login.defs defaults |
-o, --non-unique |
Allow non-unique GID |
-p, --password |
Set encrypted password |
-r, --system |
Create system group |
-h, --help |
Display help |
--version |
Show version |
Key Use Cases
- Group creation
- Access control
- Resource sharing
- System organization
- Security management
Examples with Explanations
Example 1: Basic Usage
groupadd developers
Create new group ‘developers’
Example 2: System Group
groupadd -r sysgroup
Create system group
Example 3: Specific GID
groupadd -g 1500 newgroup
Create group with specific GID
Understanding Output
- No output on success
- Error messages for:
- Group exists
- Invalid GID
- Permission denied
- Invalid group name
Common Usage Patterns
Create user group:
groupadd -f project_team
System service group:
groupadd -r service_name
Custom GID range:
groupadd -g 2000 custom_group
Security Considerations
- GID selection
- Password protection
- System vs user groups
- Access permissions
- Group hierarchy
Additional Resources
Best Practices
- Plan GID ranges
- Document group purpose
- Regular audits
- Permission review
- Naming conventions
Common Tasks
- Project groups
- Service groups
- Access control
- Resource sharing
- System organization
Group Types
- System groups
- User groups
- Project groups
- Service groups
- Administrative groups