CompTIA Linux+ (XK0-006) — All Questions

← Back to practice

4 questions

Services & User Management

Which command creates a new user with a home directory and sets bash as the login shell in one step?

  • a.usermod -aG bash alice
  • b.useradd -m -s /bin/bash alice
  • c.passwd -m alice
  • d.groupadd -s /bin/bash alice

'useradd -m -s /bin/bash alice' creates the account, makes the home directory (-m), and sets the login shell (-s). 'usermod' modifies an existing user, 'passwd' manages passwords, and 'groupadd' creates groups.

Services & User Management

Which command adds an existing user to a supplementary group without removing them from their other groups?

  • a.usermod -g developers bob
  • b.gpasswd -d bob developers
  • c.useradd -G developers bob
  • d.usermod -aG developers bob

'usermod -aG developers bob' appends (-a) the user to the supplementary group (-G) while preserving existing memberships. Omitting -a with -G replaces all supplementary groups, '-g' changes the primary group, and 'gpasswd -d' removes a member.

Services & User Management

What is the recommended way to grant a user limited sudo privileges safely?

  • a.Add a file in /etc/sudoers.d/ edited with visudo
  • b.Manually edit /etc/passwd to add root
  • c.chmod 4777 /bin/su
  • d.Add the user to /etc/shadow

Placing a drop-in file in /etc/sudoers.d/ and editing it with visudo validates syntax before saving, preventing lockouts and keeping rules modular. Editing /etc/passwd or /etc/shadow does not grant sudo, and setting 4777 on /bin/su is a serious security hole.

Services & User Management

Which command forces a user to change their password at next login?

  • a.passwd -l alice
  • b.usermod -L alice
  • c.chage -d 0 alice
  • d.chage -E 0 alice

'chage -d 0 alice' sets the last-password-change date to the epoch, forcing a change at next login. 'passwd -l' and 'usermod -L' lock the account, and 'chage -E 0' sets an account expiration date rather than forcing a password reset.

Report