A system administrator needs to add a new user 'alice' with UID 1050 and a home directory at /home/alice. Which command should be used?
Trap 1: useradd -U 1050 -h /home/alice alice
Incorrect. -U is not a valid flag (it means create group with same name but uppercase) and -h is not a valid flag; the correct flag for home directory is -d.
Trap 2: useradd --uid 1050 --home /home/alice alice
Incorrect. --home specifies the home directory but does not create it; --create-home or -m is needed to create the directory.
- A
useradd -u 1050 -d /home/alice -m alice
Correct. -u sets UID 1050, -d sets home directory to /home/alice, -m creates it.
- B
useradd -U 1050 -h /home/alice alice
Why wrong: Incorrect. -U is not a valid flag (it means create group with same name but uppercase) and -h is not a valid flag; the correct flag for home directory is -d.
- C
useradd --uid 1050 --home /home/alice alice
Why wrong: Incorrect. --home specifies the home directory but does not create it; --create-home or -m is needed to create the directory.
- D
useradd --create-home --skel /etc/skel -u 1050 alice
Correct. --create-home creates the home directory at default /home/alice, -u sets UID, and --skel specifies skeleton directory. The home directory path is /home/alice as required.