nerdexam
CompTIA

XK0-004 · Question #435

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…

The correct answer is D. useradd -d/var/www/-g service_accounts -G www -f 0. The useradd command uses distinct flags for home directory, primary group, secondary group, and password-expiry inactivity; only option D uses all four correctly.

System Management

Question

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?

Options

  • Auseradd -D/var/www/-g service_accounts -G www -c 0
  • Buseradd -d/var/www/-g service_accounts -f www -g 0
  • Cuseradd -D/var/www/-g service_accounts -g www -c 0
  • Duseradd -d/var/www/-g service_accounts -G www -f 0

How the community answered

(40 responses)
  • A
    8% (3)
  • B
    3% (1)
  • C
    5% (2)
  • D
    85% (34)

Why each option

The useradd command uses distinct flags for home directory, primary group, secondary group, and password-expiry inactivity; only option D uses all four correctly.

Auseradd -D/var/www/-g service_accounts -G www -c 0

The -D flag modifies global useradd defaults rather than setting a per-user home directory, and -c sets the GECOS comment field rather than the password inactivity period.

Buseradd -d/var/www/-g service_accounts -f www -g 0

The -f flag expects a numeric inactivity value in days, not a group name like 'www', and -g appears twice, making the command syntactically invalid.

Cuseradd -D/var/www/-g service_accounts -g www -c 0

The -D flag changes global useradd defaults instead of specifying the new user's home directory, and using -g twice attempts to assign two primary groups rather than using -G for the secondary group.

Duseradd -d/var/www/-g service_accounts -G www -f 0Correct

The -d flag sets the home directory to /var/www/, -g service_accounts assigns the primary group, -G www assigns the supplemental (secondary) group, and -f 0 disables the account immediately upon password expiry (0-day grace period). This combination satisfies all four stated requirements with no flag conflicts.

Concept tested: useradd command flags for Linux user account creation

Source: https://man7.org/linux/man-pages/man8/useradd.8.html

Topics

#useradd#user account creation#group assignment#account expiry

Community Discussion

No community discussion yet for this question.

Full XK0-004 Practice