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.
Incorrect. -G specifies supplementary groups.
useradd -s developers hanaIncorrect. -s specifies the login shell.
Incorrect. -s specifies the login shell.
useradd -d developers hanaIncorrect. -d specifies the home directory.
Incorrect. -d specifies the home directory.
useradd -g developers hanaCorrect. -g developers selects the primary group.
Correct. -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
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.