CompTIA Linux+ (XK0-004) — Question 263
A Linux administrator is creating a new local Linux user account for a web application. The account has the following requirements:
• Use /var/www as the home directory
• Have the service_accounts group as its primary group
• Have the www user group as a secondary group
• Disable the account when the password expires
Which of the following BEST meets these requirements?
Answer options
- A. useradd -D /var/www/ -g service_accounts -G www -e 0
- B. useradd -d /var/www/ -G service_accounts -f www -g 0
- C. useradd -D /var/www -G service_accounts -g www -e 0
- D. useradd -d /var/www/ -g service_accounts –G www -f 0
Correct answer: D
Explanation
Option D is correct because it properly sets the home directory to /var/www/, assigns service_accounts as the primary group, adds www as a secondary group, and uses the -f flag to disable the account when the password expires. Option A incorrectly uses -D instead of -d for the home directory, Option B uses -f with an incorrect argument, and Option C also incorrectly uses -D instead of -d for the home directory.