Create alice with /srv/home/alice as the home directory.
Which command is appropriate?
Use -d to set the home path and -m to create it and copy the template.
Detailed explanation
useradd -m /srv/home/alice aliceIncorrect. -m takes no home-path argument; -d is required.
Incorrect. -m takes no home-path argument; -d is required.
useradd -m -d /srv/home/alice aliceCorrect. -d sets the path and -m creates the directory.
Correct. -d sets the path and -m creates the directory.
useradd -s /srv/home/alice aliceIncorrect. -s selects the login shell.
Incorrect. -s selects the login shell.
useradd -g /srv/home/alice aliceIncorrect. -g selects the primary group.
Incorrect. -g selects the primary group.
Try it yourself
An example you can run in a temporary verification environment.
useradd --help 2>&1 | grep -E -- '--home-dir|--create-home'Expected result
-d/--home-dirと-m/--create-homeの説明Key points
- -d sets home path
- -m creates it
- Use both together
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.