Create user hana with existing group developers as the primary group.
Which command is appropriate?
useradd -g GROUP sets the primary group. Supplementary groups use the uppercase -G option.
Detailed explanation
useradd -G developers hanaIncorrect. -G specifies supplementary groups.
useradd -s developers hanaIncorrect. -s specifies the login shell.
useradd -d developers hanaIncorrect. -d specifies the home directory.
useradd -g developers hanaCorrect. -g developers selects the primary group.
Try it yourself
An example you can run in a temporary verification environment.
useradd --help | grep -E -- '-g,|-G,'Expected result
--gidと--groupsの説明行Key points
- Lowercase -g is primary
- Uppercase -G is supplementary
- The group should exist
Notes
- Environment: shadow-utils useradd help / 状態変更なし
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Account record
Identity attributes such as a user ID, home directory, and login shell.
Group membership
Primary and supplementary groups used during permission checks.
Password aging
State and time limits that control password changes and account access.