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

Question 350

A service account requires a narrow sudo policy stored separately from the global file. Which directory supports include-style policy fragments?

  1. /etc/sudoers.d
  2. Command-specific sudoers grant
  3. sudo -i
  4. NOEXEC sudoers tag

Explanation

Correct Answer

A:

sudo can read controlled policy fragments from sudoers.d where configured. Ownership, permissions and validation are essential for safe delegation.

Incorrect Answers

B:

Restricting the allowed executable and argument scope helps implement least privilege; it answers a neighboring question rather than storing modular sudo authorization rules.

C:

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 storing modular sudo authorization rules.

D:

NOEXEC can prevent some dynamically linked child-process execution paths under supported conditions; this does not achieve storing modular sudo authorization rules on the system described.

Question 351

A program must run with the file owner's effective UID when executed, subject to security restrictions. Which special permission applies?

  1. chattr +i settings.conf
  2. chown serviceuser:web file
  3. chmod 640 secrets.txt
  4. setuid bit on an executable
  5. setgid bit on the directory
  6. setfacl -m u:bob:r-x project/

Explanation

Correct Answer

D:

setuid changes the effective user ID of an executed program to its file owner's ID on supported filesystems. Mount options and security policies can suppress the behavior.

Incorrect Answers

A:

The immutable attribute blocks common changes, renames and deletion until removed by a sufficiently privileged actor; using it would leave executing a program with its owner's effective identity unresolved.

B:

chown can update both user and group ownership for a file; the requirement is executing a program with its owner's effective identity, outside the effect of this choice.

C:

Octal 640 maps to owner rw, group r and no permission for others; it does not deliver executing a program with its owner's effective identity, which is decisive in this scenario.

E:

A directory's setgid bit causes created entries to inherit the directory group on standard Linux filesystems; the task involves executing a program with its owner's effective identity, whereas this addresses another subsystem.

F:

setfacl adds or modifies named access-control-list entries beyond classic owner/group/other permissions; its scope differs from executing a program with its owner's effective identity, so it cannot meet the stated requirement.

Question 352

An operator must obtain a root login-style shell while retaining sudo policy checks and audit context. Which command is commonly used?

  1. Command-specific sudoers grant
  2. sudo -l -U alex
  3. /etc/sudoers.d
  4. sudo -i

Explanation

Correct Answer

D:

sudo -i starts a login-style shell as the target user, commonly root, after sudo authorization. The shell has broad privilege and should be used only when necessary.

Incorrect Answers

A:

Restricting the allowed executable and argument scope helps implement least privilege; its scope differs from starting a privileged login shell through sudo, so it cannot meet the stated requirement.

B:

sudo -l lists permitted commands for a user, subject to authorization to inspect that identity; that is not equivalent to starting a privileged login shell through sudo.

C:

sudo can read controlled policy fragments from sudoers.d where configured; the administrator instead needs starting a privileged login shell through sudo; this option serves a different purpose.

Question 353

A technician needs to see the SELinux labels printed beside a file listing. Which command is suitable?

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

Explanation

Correct Answer

B:

ls -Z displays SELinux security contexts on filesystem entries. It is a diagnostic step rather than a policy change.

Incorrect Answers

A:

semanage fcontext records persistent path-to-context mappings; this does not achieve inspecting current SELinux file security contexts on the system described.

C:

getsebool displays configured policy booleans and their states; using it would leave inspecting current SELinux file security contexts unresolved.

D:

restorecon applies the previously configured path-based SELinux contexts to existing files; the requirement is inspecting current SELinux file security contexts, outside the effect of this choice.

Question 354

A member of a designated administrative group should run one root-owned maintenance script without unrestricted shell access. Which policy design is appropriate?

  1. NOEXEC sudoers tag
  2. NOPASSWD sudoers tag
  3. Command-specific sudoers grant
  4. sudo -l -U alex

Explanation

Correct Answer

C:

Restricting the allowed executable and argument scope helps implement least privilege. General ALL access would exceed the task.

Incorrect Answers

A:

NOEXEC can prevent some dynamically linked child-process execution paths under supported conditions; the evidence calls for delegating one explicitly approved privileged operation, not merely this separate operation.

B:

NOPASSWD suppresses the password challenge for matched sudo commands; the task involves delegating one explicitly approved privileged operation, whereas this addresses another subsystem.

D:

sudo -l lists permitted commands for a user, subject to authorization to inspect that identity; that is not equivalent to delegating one explicitly approved privileged operation.

Question 355

A configuration file should resist accidental deletion and modification even by many privileged tools. Which file attribute supports that?

  1. chattr +a audit.log
  2. chattr +i settings.conf
  3. setuid bit on an executable
  4. setgid bit on the directory

Explanation

Correct Answer

B:

The immutable attribute blocks common changes, renames and deletion until removed by a sufficiently privileged actor. Filesystem support and capability restrictions apply.

Incorrect Answers

A:

The append-only attribute restricts changes to appending data; it answers a neighboring question rather than making a file immutable against routine changes.

C:

setuid changes the effective user ID of an executed program to its file owner's ID on supported filesystems; this does not achieve making a file immutable against routine changes on the system described.

D:

A directory's setgid bit causes created entries to inherit the directory group on standard Linux filesystems; it will not provide making a file immutable against routine changes under these conditions.

Question 356

The security team wants to enumerate current SELinux boolean values relevant to the web server. Which command is appropriate?

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

Explanation

Correct Answer

B:

getsebool displays configured policy booleans and their states. Filtering helps identify settings before making an authorized change.

Incorrect Answers

A:

getenforce reports Enforcing, Permissive or Disabled as appropriate; the requirement is listing relevant SELinux boolean states, outside the effect of this choice.

C:

restorecon applies the previously configured path-based SELinux contexts to existing files; the evidence calls for listing relevant SELinux boolean states, not merely this separate operation.

D:

semanage fcontext records persistent path-to-context mappings; the task involves listing relevant SELinux boolean states, whereas this addresses another subsystem.

E:

sealert analyzes SELinux denial events and suggests possible causes or remediation paths; its scope differs from listing relevant SELinux boolean states, so it cannot meet the stated requirement.

Question 357

Users share /tmp-like storage and should not delete each other's files merely because the directory is writable. Which bit is needed?

  1. chmod 640 secrets.txt
  2. Sticky bit on the directory
  3. setgid bit on the directory
  4. chown serviceuser:web file

Explanation

Correct Answer

B:

The sticky bit restricts unlink and rename in writable directories to permitted owners or privileged users. It does not make individual file contents confidential.

Incorrect Answers

A:

Octal 640 maps to owner rw, group r and no permission for others; that is not equivalent to protecting other users' files in a shared writable directory.

C:

A directory's setgid bit causes created entries to inherit the directory group on standard Linux filesystems; it answers a neighboring question rather than protecting other users' files in a shared writable directory.

D:

chown can update both user and group ownership for a file; that changes a different part of the system; the requested outcome is protecting other users' files in a shared writable directory.

Question 358

A user's SSH private key should be readable only by its owner to satisfy common OpenSSH checks. Which mode is appropriate?

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

Explanation

Correct Answer

A:

Mode 600 grants owner read/write and denies group or other access to the private key. Protecting the key file prevents casual credential disclosure.

Incorrect Answers

B:

This sshd_config setting denies root authentication through SSH when applied to the active configuration; using it would leave protecting a private SSH key against other users unresolved.

C:

Local forwarding binds a local port and carries connections through the SSH session to the destination; the requirement is protecting a private SSH key against other users, outside the effect of this choice.

D:

This sshd setting disallows the password authentication method, encouraging approved key-based access; it does not deliver protecting a private SSH key against other users, which is decisive in this scenario.

Question 359

A production server must forbid interactive SSH login by root using sshd policy. Which directive handles this?

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

Explanation

Correct Answer

D:

This sshd_config setting denies root authentication through SSH when applied to the active configuration. It does not remove the local root account.

Incorrect Answers

A:

Local forwarding binds a local port and carries connections through the SSH session to the destination; the task involves disabling remote SSH root logins, whereas this addresses another subsystem.

B:

Mode 600 grants owner read/write and denies group or other access to the private key; its scope differs from disabling remote SSH root logins, so it cannot meet the stated requirement.

C:

This sshd setting disallows the password authentication method, encouraging approved key-based access; that is not equivalent to disabling remote SSH root logins.

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.

CompTIA Linux+ (XK0-006) Practice Tests