Change alice's home to /srv/home/alice and move the existing home contents there.
Which command is appropriate?
usermod -d NEW_HOME -m USER changes the home field and moves existing contents.
Detailed explanation
usermod -m /srv/home/alice aliceIncorrect. -m alone does not specify the new home path.
Incorrect. -m alone does not specify the new home path.
usermod -d /srv/home/alice aliceIncorrect. -d alone changes the field but does not move existing contents.
Incorrect. -d alone changes the field but does not move existing contents.
usermod -d /srv/home/alice -m aliceCorrect. -d selects the destination and -m moves the old home.
Correct. -d selects the destination and -m moves the old home.
useradd -d /srv/home/alice -m aliceIncorrect. useradd is for creating a new account.
Incorrect. useradd is for creating a new account.
Try it yourself
An example you can run in a temporary verification environment.
usermod --help 2>&1 | grep -E -- '--home|--move-home'Expected result
-d/--homeと-m/--move-homeの説明Key points
- -d new path
- -m moves contents
- For existing users
Notes
- Environment: shadow-utils usermod / 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.