Create web01's home and copy initial files from /opt/web-skel instead of /etc/skel.
Which command is appropriate?
useradd -m -k SKEL_DIR creates the home and copies initial files from the chosen skeleton directory.
Detailed explanation
useradd -m -k /opt/web-skel web01Correct. It creates the home and uses /opt/web-skel as the template.
Correct. It creates the home and uses /opt/web-skel as the template.
useradd -d /opt/web-skel web01Incorrect. -d would register /opt/web-skel as the user's home.
Incorrect. -d would register /opt/web-skel as the user's home.
useradd -s /opt/web-skel web01Incorrect. -s selects the login shell.
Incorrect. -s selects the login shell.
useradd -M -k /opt/web-skel web01Incorrect. -M disables home creation.
Incorrect. -M disables home creation.
Try it yourself
An example you can run in a temporary verification environment.
useradd --help | grep -E -- '-k,|-m,'Expected result
--skelと--create-homeの説明行Key points
- -k selects the skeleton directory
- -m creates the home
- Different role from -d
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.