Create alice with numeric UID 2200, which is unused.
Which command is appropriate?
useradd -u UID assigns an explicit numeric UID; check for collisions and local policy first.
Detailed explanation
useradd -g 2200 aliceIncorrect. -g specifies a primary group.
Incorrect. -g specifies a primary group.
useradd -p 2200 aliceIncorrect. -p supplies an encrypted password field.
Incorrect. -p supplies an encrypted password field.
useradd -e 2200 aliceIncorrect. -e sets an account expiration date.
Incorrect. -e sets an account expiration date.
useradd -u 2200 aliceCorrect. -u 2200 assigns UID 2200.
Correct. -u 2200 assigns UID 2200.
Try it yourself
An example you can run in a temporary verification environment.
useradd --help 2>&1 | grep -E -- '--uid|-u,' | head -n 1Expected result
-uまたは--uidの説明Key points
- -u sets UID
- -g sets primary group
- Check uniqueness
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.