Create alice as a member of both the audio and video supplementary groups.
Which command is appropriate?
useradd -G GROUP1,GROUP2 supplies a comma-separated supplementary-group list.
Detailed explanation
useradd -g audio,video aliceIncorrect. -g selects one primary group.
Incorrect. -g selects one primary group.
useradd -G audio,video aliceCorrect. -G accepts the supplementary groups as a comma-separated list.
Correct. -G accepts the supplementary groups as a comma-separated list.
useradd -a audio,video aliceIncorrect. useradd does not use standalone -a for this purpose.
Incorrect. useradd does not use standalone -a for this purpose.
groupmod -G audio,video aliceIncorrect. groupmod changes group attributes, not a user's membership.
Incorrect. groupmod changes group attributes, not a user's membership.
Try it yourself
An example you can run in a temporary verification environment.
useradd --help 2>&1 | grep -E -- '--groups|-G,' | head -n 1Expected result
-Gまたは--groupsの説明Key points
- -G supplementary groups
- Comma-separated list
- Different from -g
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.