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

Question 360

Filesystem administrators want to confirm whether user alex has permission to execute a particular sudo command. Which inspection command is suitable?

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

Explanation

Correct Answer

D:

sudo -l lists permitted commands for a user, subject to authorization to inspect that identity. It exposes sudo policy rather than Linux ACLs.

Incorrect Answers

A:

visudo validates syntax before installing edits and uses locking to limit concurrent edits; that changes a different part of the system; the requested outcome is auditing an account's sudo command grants.

B:

sudo -i starts a login-style shell as the target user, commonly root, after sudo authorization; this does not achieve auditing an account's sudo command grants on the system described.

C:

NOEXEC can prevent some dynamically linked child-process execution paths under supported conditions; it will not provide auditing an account's sudo command grants under these conditions.

Question 361

An administrator needs a secure local tunnel from localhost:15432 to a database reachable from a bastion. Which SSH option fits?

  1. PermitRootLogin no
  2. chmod 600 ~/.ssh/id_ed25519
  3. ssh -L 15432:db.internal:5432 bastion
  4. PasswordAuthentication no

Explanation

Correct Answer

C:

Local forwarding binds a local port and carries connections through the SSH session to the destination. It is not the same as opening a public database listener.

Incorrect Answers

A:

This sshd_config setting denies root authentication through SSH when applied to the active configuration; it does not deliver creating a local SSH port-forward tunnel, which is decisive in this scenario.

B:

Mode 600 grants owner read/write and denies group or other access to the private key; the evidence calls for creating a local SSH port-forward tunnel, not merely this separate operation.

D:

This sshd setting disallows the password authentication method, encouraging approved key-based access; its scope differs from creating a local SSH port-forward tunnel, so it cannot meet the stated requirement.

Question 362

An operator needs the current SELinux enforcement mode in one command. Which utility returns it?

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

Explanation

Correct Answer

B:

getenforce reports Enforcing, Permissive or Disabled as appropriate. It does not modify a policy boolean or relabel files.

Incorrect Answers

A:

semanage fcontext records persistent path-to-context mappings; the administrator instead needs checking the SELinux mode; this option serves a different purpose.

C:

sealert analyzes SELinux denial events and suggests possible causes or remediation paths; that changes a different part of the system; the requested outcome is checking the SELinux mode.

D:

restorecon applies the previously configured path-based SELinux contexts to existing files; this does not achieve checking the SELinux mode on the system described.

E:

setsebool changes a named SELinux boolean, and -P stores the change persistently; it will not provide checking the SELinux mode under these conditions.

Question 363

A daemon must be allowed to make network connections under a supported policy boolean, without disabling SELinux. Which command can set a persistent boolean?

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

Explanation

Correct Answer

B:

setsebool changes a named SELinux boolean, and -P stores the change persistently. The boolean must be appropriate for the actual service behavior.

Incorrect Answers

A:

Permissive mode records would-be access denials but generally does not enforce blocking for them; using it would leave enabling a specific SELinux policy capability persistently unresolved.

C:

getenforce reports Enforcing, Permissive or Disabled as appropriate; it does not deliver enabling a specific SELinux policy capability persistently, which is decisive in this scenario.

D:

semanage fcontext records persistent path-to-context mappings; the evidence calls for enabling a specific SELinux policy capability persistently, not merely this separate operation.

Question 364

SSH should accept public keys while refusing direct password authentication for ordinary users. Which configuration is relevant?

  1. PermitRootLogin no
  2. chmod 600 ~/.ssh/id_ed25519
  3. PasswordAuthentication no
  4. ssh -L 15432:db.internal:5432 bastion
  5. setfacl -m u:bob:r-x project/
  6. chattr +i settings.conf

Explanation

Correct Answer

C:

This sshd setting disallows the password authentication method, encouraging approved key-based access. Other methods such as keyboard-interactive may also need review.

Incorrect Answers

A:

This sshd_config setting denies root authentication through SSH when applied to the active configuration; its scope differs from disabling the SSH password authentication method, so it cannot meet the stated requirement.

B:

Mode 600 grants owner read/write and denies group or other access to the private key; that is not equivalent to disabling the SSH password authentication method.

D:

Local forwarding binds a local port and carries connections through the SSH session to the destination; it answers a neighboring question rather than disabling the SSH password authentication method.

E:

setfacl adds or modifies named access-control-list entries beyond classic owner/group/other permissions; that changes a different part of the system; the requested outcome is disabling the SSH password authentication method.

F:

The immutable attribute blocks common changes, renames and deletion until removed by a sufficiently privileged actor; this does not achieve disabling the SSH password authentication method on the system described.

Question 365

A technician should edit a sudoers entry while preventing invalid syntax from breaking administrative access. Which utility is appropriate?

  1. NOPASSWD sudoers tag
  2. visudo
  3. sudo -i
  4. sudo -l -U alex

Explanation

Correct Answer

B:

visudo validates syntax before installing edits and uses locking to limit concurrent edits. Editing sudoers directly with an arbitrary text editor is risky.

Incorrect Answers

A:

NOPASSWD suppresses the password challenge for matched sudo commands; this does not achieve safely validating sudo policy edits on the system described.

C:

sudo -i starts a login-style shell as the target user, commonly root, after sudo authorization; using it would leave safely validating sudo policy edits unresolved.

D:

sudo -l lists permitted commands for a user, subject to authorization to inspect that identity; the requirement is safely validating sudo policy edits, outside the effect of this choice.

Question 366

A privileged maintenance command should be invokable without a password prompt only after risk approval. Which sudoers tag allows that?

  1. NOPASSWD sudoers tag
  2. NOEXEC sudoers tag
  3. visudo
  4. Command-specific sudoers grant

Explanation

Correct Answer

A:

NOPASSWD suppresses the password challenge for matched sudo commands. It weakens a useful interactive guard and demands tightly scoped grants.

Incorrect Answers

B:

NOEXEC can prevent some dynamically linked child-process execution paths under supported conditions; the task involves disabling sudo password prompting for a specific grant, whereas this addresses another subsystem.

C:

visudo validates syntax before installing edits and uses locking to limit concurrent edits; its scope differs from disabling sudo password prompting for a specific grant, so it cannot meet the stated requirement.

D:

Restricting the allowed executable and argument scope helps implement least privilege; that is not equivalent to disabling sudo password prompting for a specific grant.

Question 367

An AVC denial should be interpreted and turned into a human-readable investigation report. Which tool can explain policy denial messages?

  1. sealert
  2. ls -Z /srv/site
  3. semanage fcontext -a -t httpd_sys_content_t '/srv/site(/.*)?'
  4. getsebool -a | grep httpd

Explanation

Correct Answer

A:

sealert analyzes SELinux denial events and suggests possible causes or remediation paths. Suggestions should be reviewed before policy changes.

Incorrect Answers

B:

ls -Z displays SELinux security contexts on filesystem entries; that changes a different part of the system; the requested outcome is interpreting SELinux access-vector-cache denials.

C:

semanage fcontext records persistent path-to-context mappings; this does not achieve interpreting SELinux access-vector-cache denials on the system described.

D:

getsebool displays configured policy booleans and their states; it will not provide interpreting SELinux access-vector-cache denials under these conditions.

Question 368

A project directory should receive a read-only ACL entry for contractor bob without changing its main group. Which command fits?

  1. chattr +i settings.conf
  2. setfacl -m u:bob:r-x project/
  3. chattr +a audit.log
  4. chown serviceuser:web file

Explanation

Correct Answer

B:

setfacl adds or modifies named access-control-list entries beyond classic owner/group/other permissions. The effective ACL mask can restrict granted permissions.

Incorrect Answers

A:

The immutable attribute blocks common changes, renames and deletion until removed by a sufficiently privileged actor; the requirement is granting a named user's directory ACL permissions, outside the effect of this choice.

C:

The append-only attribute restricts changes to appending data; the evidence calls for granting a named user's directory ACL permissions, not merely this separate operation.

D:

chown can update both user and group ownership for a file; the task involves granting a named user's directory ACL permissions, whereas this addresses another subsystem.

Question 369

A file must allow the owner to read/write, group to read, and others no access. Which mode is correct?

  1. setuid bit on an executable
  2. chown serviceuser:web file
  3. setfacl -m u:bob:r-x project/
  4. chmod 640 secrets.txt
  5. umask 027

Explanation

Correct Answer

D:

Octal 640 maps to owner rw, group r and no permission for others. On ordinary files the execute bit is not implied.

Incorrect Answers

A:

setuid changes the effective user ID of an executed program to its file owner's ID on supported filesystems; that is not equivalent to setting owner read/write and group read permissions.

B:

chown can update both user and group ownership for a file; the administrator instead needs setting owner read/write and group read permissions; this option serves a different purpose.

C:

setfacl adds or modifies named access-control-list entries beyond classic owner/group/other permissions; it answers a neighboring question rather than setting owner read/write and group read permissions.

E:

Applying umask 027 to default file permissions 666 yields 640; this does not achieve setting owner read/write and group read permissions on the system described.

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.

CompTIA Linux+ (XK0-006) Practice Tests