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

Question 370

An SELinux-protected web server now serves documents from /srv/site. The administrator must make the new labeling rule persistent and apply it to existing files. Which TWO utilities achieve this? Choose TWO.

  1. sealert
  2. SELinux permissive mode
  3. semanage fcontext -a -t httpd_sys_content_t '/srv/site(/.*)?'
  4. setsebool -P httpd_can_network_connect on
  5. restorecon -Rv /srv/site

Explanation

Correct Answers

C:

semanage fcontext records persistent path-to-context mappings. A subsequent restorecon applies the saved policy mapping to existing files.

E:

restorecon applies SELinux file labels to existing paths according to the persistent file-context mappings. After semanage fcontext records the custom /srv/site rule, restorecon -Rv /srv/site labels the files accordingly.

Incorrect Answers

A:

sealert analyzes SELinux denial events and suggests possible causes or remediation paths; it will not provide defining and applying persistent SELinux context mapping under these conditions.

B:

Permissive mode records would-be access denials but generally does not enforce blocking for them; using it would leave defining and applying persistent SELinux context mapping unresolved.

D:

setsebool changes a named SELinux boolean, and -P stores the change persistently; it does not deliver defining and applying persistent SELinux context mapping, which is decisive in this scenario.

Question 371

An audit log should accept appends but reject truncation and ordinary overwrites on a supporting filesystem. Which attribute is relevant?

  1. chown serviceuser:web file
  2. chattr +i settings.conf
  3. umask 027
  4. chattr +a audit.log

Explanation

Correct Answer

D:

The append-only attribute restricts changes to appending data. Appropriate privileges can alter the attribute, so it is not an external tamper-proof log archive.

Incorrect Answers

A:

chown can update both user and group ownership for a file; the task involves restricting a file to append operations, whereas this addresses another subsystem.

B:

The immutable attribute blocks common changes, renames and deletion until removed by a sufficiently privileged actor; its scope differs from restricting a file to append operations, so it cannot meet the stated requirement.

C:

Applying umask 027 to default file permissions 666 yields 640; that is not equivalent to restricting a file to append operations.

Question 372

An application launched via sudo should not be able to execute further commands through a pager escape when the policy supports that control. Which sudoers feature helps?

  1. sudo -i
  2. NOEXEC sudoers tag
  3. su - targetuser
  4. sudo -l -U alex

Explanation

Correct Answer

B:

NOEXEC can prevent some dynamically linked child-process execution paths under supported conditions. It is defense in depth, not a universal sandbox.

Incorrect Answers

A:

sudo -i starts a login-style shell as the target user, commonly root, after sudo authorization; that changes a different part of the system; the requested outcome is restricting subprocess execution from an approved sudo command.

C:

su - starts a login shell for the target identity and resets relevant environment values; it will not provide restricting subprocess execution from an approved sudo command under these conditions.

D:

sudo -l lists permitted commands for a user, subject to authorization to inspect that identity; using it would leave restricting subprocess execution from an approved sudo command unresolved.

Question 373

An SELinux administrator has configured a persistent file-context mapping for /srv/site. Before changing any file labels, the administrator wants to ask the policy what security context a named path should have by default. Which utility fits?

  1. matchpathcon /srv/site/index.html
  2. restorecon -Rv /srv/site
  3. ls -Z /srv/site/index.html
  4. chcon -t httpd_sys_content_t /srv/site/index.html
  5. getenforce

Explanation

Correct Answer

A:

matchpathcon consults SELinux file-context specifications and reports the default context expected for the path. It allows the administrator to preview the policy result without changing the file.

Incorrect Answers

B:

restorecon applies policy-defined contexts to existing filesystem objects. That changes labels, whereas the question requires a non-mutating lookup first.

C:

ls -Z displays the context currently stored on the file. That current label may differ from the context expected under the persistent file-context mapping.

D:

chcon changes the current context directly, typically without creating a persistent path rule. It does not merely report what SELinux policy would assign.

E:

getenforce reports whether SELinux is Enforcing, Permissive or Disabled. That operating mode says nothing about the default context for an individual file.

Question 374

Remote SSH administrators should prove server identity to avoid connecting to a spoofed host. Which practice is important?

  1. Just-in-time elevation with logged approvals
  2. Lock unused authentication methods on service accounts
  3. Verify the SSH host key fingerprint
  4. Retrieve secrets through a controlled secret store

Explanation

Correct Answer

C:

Host-key checking establishes continuity of the remote server's identity. Ignoring unexpected key changes can enable interception.

Incorrect Answers

A:

Time-bounded elevation reduces standing privilege and records authorization decisions; the administrator instead needs validating the remote server's SSH identity; this option serves a different purpose.

B:

Disabling unnecessary password or SSH login paths narrows attack surface; it answers a neighboring question rather than validating the remote server's SSH identity.

D:

A managed secret mechanism can limit access, enable rotation and avoid publishing credentials with scripts; this does not achieve validating the remote server's SSH identity on the system described.

Question 375

A staff member leaves, and the company needs to deny future login while preserving files pending investigation. Which action is most appropriate?

  1. Individual named accounts with audited sudo
  2. Cgroup-based service resource limits
  3. Disable or expire the user account
  4. /usr/sbin/nologin
  5. Run services with dedicated least-privileged identities

Explanation

Correct Answer

C:

Locking or expiring access protects the system without immediately destroying evidence. SSH keys, tokens and centrally granted sessions should also be reviewed.

Incorrect Answers

A:

Named identities allow per-user authentication and privilege grants with accountability; using it would leave revoking access without deleting retained data unresolved.

B:

Control groups bound resource usage of process groups and can be managed by systemd; the requirement is revoking access without deleting retained data, outside the effect of this choice.

D:

nologin refuses interactive shell sessions while allowing the account to own processes and files; the evidence calls for revoking access without deleting retained data, not merely this separate operation.

E:

Constraining service UIDs and filesystem privileges limits damage if an application is compromised; the task involves revoking access without deleting retained data, whereas this addresses another subsystem.

Question 376

An account should be required to change its password after 90 days in an environment with that policy. Which local utility manages aging?

  1. PAM password-history enforcement
  2. PAM failed-login counter policy
  3. Prefer sufficient password length and resistance to guessing
  4. chage -M 90 username

Explanation

Correct Answer

D:

chage -M sets a maximum password age in days. Expiration policies should reflect the organization's threat model and central identity integration.

Incorrect Answers

A:

PAM modules can remember previous password hashes and reject reuse on password change; its scope differs from setting a local maximum password age, so it cannot meet the stated requirement.

B:

A PAM module such as pam_faillock can record failed attempts and enforce temporary denial according to configuration; that is not equivalent to setting a local maximum password age.

C:

Password length and unpredictability help resist brute force and dictionary attacks; the administrator instead needs setting a local maximum password age; this option serves a different purpose.

Question 377

The team needs to limit CPU and memory consumption for a sensitive service independent of its user account. Which containment mechanism helps?

  1. PAM failed-login counter policy
  2. Disable or expire the user account
  3. Cgroup-based service resource limits
  4. /usr/sbin/nologin
  5. Run services with dedicated least-privileged identities
  6. Individual named accounts with audited sudo

Explanation

Correct Answer

C:

Control groups bound resource usage of process groups and can be managed by systemd. File permission bits do not enforce memory or CPU quotas.

Incorrect Answers

A:

A PAM module such as pam_faillock can record failed attempts and enforce temporary denial according to configuration; this does not achieve constraining a daemon's CPU and memory usage on the system described.

B:

Locking or expiring access protects the system without immediately destroying evidence; it will not provide constraining a daemon's CPU and memory usage under these conditions.

D:

nologin refuses interactive shell sessions while allowing the account to own processes and files; the requirement is constraining a daemon's CPU and memory usage, outside the effect of this choice.

E:

Constraining service UIDs and filesystem privileges limits damage if an application is compromised; it does not deliver constraining a daemon's CPU and memory usage, which is decisive in this scenario.

F:

Named identities allow per-user authentication and privilege grants with accountability; the evidence calls for constraining a daemon's CPU and memory usage, not merely this separate operation.

Question 378

An account password needs to be changed securely by its authorized owner. Which utility is conventional?

  1. chage -M 90 username
  2. Prefer sufficient password length and resistance to guessing
  3. PAM failed-login counter policy
  4. passwd

Explanation

Correct Answer

D:

passwd interacts with the authentication stack to change local passwords and enforce applicable policy. It should not require manually editing hashed shadow fields.

Incorrect Answers

A:

chage -M sets a maximum password age in days; the evidence calls for changing an account password through supported tooling, not merely this separate operation.

B:

Password length and unpredictability help resist brute force and dictionary attacks; the task involves changing an account password through supported tooling, whereas this addresses another subsystem.

C:

A PAM module such as pam_faillock can record failed attempts and enforce temporary denial according to configuration; its scope differs from changing an account password through supported tooling, so it cannot meet the stated requirement.

Question 379

Local accounts must use long memorable passphrases rather than short complex passwords. Which security principle is most relevant?

  1. passwd
  2. Prefer sufficient password length and resistance to guessing
  3. PAM password-history enforcement
  4. PAM failed-login counter policy

Explanation

Correct Answer

B:

Password length and unpredictability help resist brute force and dictionary attacks. Mandatory complexity alone does not guarantee strength.

Incorrect Answers

A:

passwd interacts with the authentication stack to change local passwords and enforce applicable policy; it answers a neighboring question rather than improving password resistance through sufficient length.

C:

PAM modules can remember previous password hashes and reject reuse on password change; this does not achieve improving password resistance through sufficient length on the system described.

D:

A PAM module such as pam_faillock can record failed attempts and enforce temporary denial according to configuration; it will not provide improving password resistance through sufficient length under these conditions.

Question 380

A shared administrator password makes it impossible to attribute maintenance commands to a person. Which alternative is preferred?

  1. Run services with dedicated least-privileged identities
  2. /usr/sbin/nologin
  3. Individual named accounts with audited sudo
  4. Disable or expire the user account

Explanation

Correct Answer

C:

Named identities allow per-user authentication and privilege grants with accountability. Shared root credentials obscure attribution and complicate revocation.

Incorrect Answers

A:

Constraining service UIDs and filesystem privileges limits damage if an application is compromised; the requirement is maintaining accountable privileged administration, outside the effect of this choice.

B:

nologin refuses interactive shell sessions while allowing the account to own processes and files; it does not deliver maintaining accountable privileged administration, which is decisive in this scenario.

D:

Locking or expiring access protects the system without immediately destroying evidence; the task involves maintaining accountable privileged administration, whereas this addresses another subsystem.

CompTIA Linux+ (XK0-006) Practice Tests