CompTIA XK0-006 (CompTIA Linux+) Practice Test 20

Question 190

A group previously named devops must be renamed without changing its numeric GID. Which utility supports this?

  1. usermod -e 2026-12-31 tempuser
  2. groupmod -n platform devops
  3. usermod -d /home/new -m sam
  4. chage -d 0 sam

Explanation

Correct Answer

B:

groupmod -n changes the local group name while preserving its identity number. Existing filesystem permissions normally continue using the same GID.

Incorrect Answers

A:

usermod -e sets the account's expiration date in the local account database; it will not provide changing a local group name under these conditions.

C:

usermod -d changes the recorded home location and -m moves content when supported; the requirement is changing a local group name, outside the effect of this choice.

D:

chage -d 0 marks the password as requiring change at next password-based login; it does not deliver changing a local group name, which is decisive in this scenario.

Question 191

An employee must choose a new password at their next authentication. Which command expires the current password immediately?

  1. usermod -d /home/new -m sam
  2. chage -d 0 sam
  3. userdel -r formeruser
  4. groupmod -n platform devops

Explanation

Correct Answer

B:

chage -d 0 marks the password as requiring change at next password-based login. The behavior depends on the authentication stack and account policies.

Incorrect Answers

A:

usermod -d changes the recorded home location and -m moves content when supported; the task involves forcing password change at next login, whereas this addresses another subsystem.

C:

userdel -r removes the account and associated home and mail spool when supported; that is not equivalent to forcing password change at next login.

D:

groupmod -n changes the local group name while preserving its identity number; the administrator instead needs forcing password change at next login; this option serves a different purpose.

Question 192

A service must query identity information through NSS rather than reading /etc/passwd directly. Which command is appropriate?

  1. id
  2. who
  3. getent passwd appuser
  4. whoami

Explanation

Correct Answer

C:

getent consults configured Name Service Switch backends, including remote directories where configured. It can return identities not present in local passwd files.

Incorrect Answers

A:

id shows real and effective user/group IDs and group membership; that changes a different part of the system; the requested outcome is resolving an account through NSS.

B:

who reports login records such as username, terminal and time from system accounting data; this does not achieve resolving an account through NSS on the system described.

D:

whoami outputs the name corresponding to the effective user ID; using it would leave resolving an account through NSS unresolved.

Question 193

A script needs the effective identity and group identifiers of the running process. Which command reports those details?

  1. lastlog
  2. getent passwd appuser
  3. id
  4. whoami
  5. who

Explanation

Correct Answer

C:

id shows real and effective user/group IDs and group membership. It gives a fuller numeric identity view than a username-only command.

Incorrect Answers

A:

lastlog reads last-login accounting records for users; it does not deliver displaying UID and GID context, which is decisive in this scenario.

B:

getent consults configured Name Service Switch backends, including remote directories where configured; the evidence calls for displaying UID and GID context, not merely this separate operation.

D:

whoami outputs the name corresponding to the effective user ID; its scope differs from displaying UID and GID context, so it cannot meet the stated requirement.

E:

who reports login records such as username, terminal and time from system accounting data; that is not equivalent to displaying UID and GID context.

Question 194

An administrator needs to see the users currently logged in and their terminals. Which command provides a concise list?

  1. getent passwd appuser
  2. id
  3. whoami
  4. who

Explanation

Correct Answer

D:

who reports login records such as username, terminal and time from system accounting data. It is not a history of all past logins.

Incorrect Answers

A:

getent consults configured Name Service Switch backends, including remote directories where configured; the administrator instead needs listing currently established user sessions; this option serves a different purpose.

B:

id shows real and effective user/group IDs and group membership; it answers a neighboring question rather than listing currently established user sessions.

C:

whoami outputs the name corresponding to the effective user ID; that changes a different part of the system; the requested outcome is listing currently established user sessions.

Question 195

New home directories must contain a default README and shell startup files. Which system path provides the template?

  1. /etc/skel
  2. lastlog
  3. /etc/group
  4. /etc/profile
  5. /etc/shadow
  6. /etc/passwd

Explanation

Correct Answer

A:

Account-creation utilities can copy skeleton-directory contents into a newly created home. Updating this template does not automatically rewrite existing users' files.

Incorrect Answers

B:

lastlog reads last-login accounting records for users; the requirement is populating new home-directory templates, outside the effect of this choice.

C:

/etc/group maps group names to GIDs and lists members for local group records; it does not deliver populating new home-directory templates, which is decisive in this scenario.

D:

/etc/profile establishes system-wide login-shell environment defaults for Bourne-style shells; the evidence calls for populating new home-directory templates, not merely this separate operation.

E:

/etc/shadow stores password hashes and aging controls with restricted access; the task involves populating new home-directory templates, whereas this addresses another subsystem.

F:

/etc/passwd holds local account records with identity fields and login shell; its scope differs from populating new home-directory templates, so it cannot meet the stated requirement.

Question 196

A departed contractor's password login should be disabled without deleting the account history. Which command locks the local password?

  1. userdel -r formeruser
  2. usermod -d /home/new -m sam
  3. passwd -l contractor
  4. chage -d 0 sam

Explanation

Correct Answer

C:

passwd -l locks password authentication by modifying the stored password field. Existing SSH keys or other authentication paths may require additional control.

Incorrect Answers

A:

userdel -r removes the account and associated home and mail spool when supported; its scope differs from locking password-based sign-in while retaining an account, so it cannot meet the stated requirement.

B:

usermod -d changes the recorded home location and -m moves content when supported; that is not equivalent to locking password-based sign-in while retaining an account.

D:

chage -d 0 marks the password as requiring change at next password-based login; it answers a neighboring question rather than locking password-based sign-in while retaining an account.

Question 197

A password audit requires aging fields and protected password hashes. Which account file holds them?

  1. /etc/skel
  2. /etc/shadow
  3. /etc/profile
  4. /etc/passwd

Explanation

Correct Answer

B:

/etc/shadow stores password hashes and aging controls with restricted access. It should not be made world-readable for reporting.

Incorrect Answers

A:

Account-creation utilities can copy skeleton-directory contents into a newly created home; this does not achieve locating local password hashes and aging metadata on the system described.

C:

/etc/profile establishes system-wide login-shell environment defaults for Bourne-style shells; using it would leave locating local password hashes and aging metadata unresolved.

D:

/etc/passwd holds local account records with identity fields and login shell; the requirement is locating local password hashes and aging metadata, outside the effect of this choice.

Question 198

A new group must use GID 4500 to match an external filesystem's numeric ownership. Which command fits?

  1. useradd -m -d /home/deploy deploy
  2. groupadd -g 4500 media
  3. groupadd auditors
  4. usermod -s /bin/bash sam

Explanation

Correct Answer

B:

groupadd -g sets a particular local group ID if it is not already used, unless explicit nonunique behavior is allowed. Filesystems store numeric IDs for owners.

Incorrect Answers

A:

useradd creates the account, while -m requests creation of its home and -d selects the path; the evidence calls for choosing a group's exact numeric identifier, not merely this separate operation.

C:

groupadd registers a local group in the system account database; its scope differs from choosing a group's exact numeric identifier, so it cannot meet the stated requirement.

D:

usermod -s updates the shell entry in the account database; that is not equivalent to choosing a group's exact numeric identifier.

Question 199

A user complains that a different account is being used in a shell session. Which command shows the current effective username?

  1. id
  2. whoami
  3. getent passwd appuser
  4. lastlog

Explanation

Correct Answer

B:

whoami outputs the name corresponding to the effective user ID. After sudo or su this can differ from the original login identity.

Incorrect Answers

A:

id shows real and effective user/group IDs and group membership; it answers a neighboring question rather than identifying the effective username.

C:

getent consults configured Name Service Switch backends, including remote directories where configured; this does not achieve identifying the effective username on the system described.

D:

lastlog reads last-login accounting records for users; it will not provide identifying the effective username under these conditions.

Question 200

An existing employee should be assigned a new home directory path and existing home contents should move too. Which command combination fits?

  1. usermod -d /home/new -m sam
  2. groupmod -n platform devops
  3. userdel -r formeruser
  4. chage -d 0 sam
  5. usermod -e 2026-12-31 tempuser

Explanation

Correct Answer

A:

usermod -d changes the recorded home location and -m moves content when supported. Permissions and destination existence must be checked.

Incorrect Answers

B:

groupmod -n changes the local group name while preserving its identity number; it does not deliver moving a user's home and updating the account record, which is decisive in this scenario.

C:

userdel -r removes the account and associated home and mail spool when supported; the evidence calls for moving a user's home and updating the account record, not merely this separate operation.

D:

chage -d 0 marks the password as requiring change at next password-based login; the task involves moving a user's home and updating the account record, whereas this addresses another subsystem.

E:

usermod -e sets the account's expiration date in the local account database; its scope differs from moving a user's home and updating the account record, so it cannot meet the stated requirement.

CompTIA Linux+ (XK0-006) Practice Tests