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.
useradd -m -d /srv/home/app01 app01Correct. It specifies the path and creates the home directory.
useradd -m -s /srv/home/app01 app01Incorrect. -s sets the login shell.
useradd -M -d /srv/home/app01 app01Incorrect. -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
Account record
Identity attributes such as a user ID, home directory, and login shell.
Group membership
Primary and supplementary groups used during permission checks.
Password aging
State and time limits that control password changes and account access.