Create user app01 and create its home directory at /srv/home/app01.
Which command is appropriate?
Use -d to set the home path and -m to create that directory. Registration and physical creation are separate options.
Detailed explanation
useradd -d /srv/home/app01 app01Incorrect. -d registers the path but without -m creation depends on defaults.
Incorrect. -d registers the path but without -m creation depends on defaults.
useradd -m -d /srv/home/app01 app01Correct. It specifies the path and creates the home directory.
Correct. It specifies the path and creates the home directory.
useradd -m -s /srv/home/app01 app01Incorrect. -s sets the login shell.
Incorrect. -s sets the login shell.
useradd -M -d /srv/home/app01 app01Incorrect. -M explicitly disables creation.
Incorrect. -M explicitly disables creation.
Try it yourself
An example you can run in a temporary verification environment.
useradd --help | grep -E -- '-d,|-m,'Expected result
--home-dirと--create-homeの説明行Key points
- -d sets the home path
- -m creates the directory
- Separate registration from creation
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.