Create user ops01 and create its home directory in the default location.
Which command is appropriate?
useradd -m creates the account and creates the home directory when it does not already exist.
Detailed explanation
useradd -m ops01Correct. -m requests creation of the default home directory.
Correct. -m requests creation of the default home directory.
useradd -M ops01Incorrect. -M prevents home-directory creation.
Incorrect. -M prevents home-directory creation.
mkdir -m ops01Incorrect. mkdir creates directories, not user accounts.
Incorrect. mkdir creates directories, not user accounts.
usermod -m ops01Incorrect. usermod changes an existing account; -m moves a home with -d.
Incorrect. usermod changes an existing account; -m moves a home with -d.
Try it yourself
An example you can run in a temporary verification environment.
useradd --help | grep -E -- '-m,|--create-home'Expected result
-mまたは--create-homeの説明行Key points
- useradd creates a user
- -m creates the home
- -M disables home 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.