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

Question 340

A Linux gateway runs a local transparent HTTP proxy on port 3128. Incoming TCP requests addressed to port 80 should be intercepted by that gateway itself, without a separate destination server address. Which nftables NAT statement fits?

  1. redirect to :3128
  2. masquerade
  3. snat to 198.51.100.10
  4. ct state established
  5. drop

Explanation

Correct Answer

A:

The nftables redirect statement changes the destination to a local socket on the gateway. In an appropriate NAT chain matching TCP port 80, it can deliver traffic to the local proxy on port 3128.

Incorrect Answers

B:

Masquerading changes the source address for outbound NAT traffic. It does not move inbound HTTP traffic to a different local listener port.

C:

Static source NAT changes where a packet appears to originate. It leaves the requested local destination-port interception unimplemented.

D:

Connection-state matching classifies an existing flow but does not perform destination translation. It cannot redirect new inbound requests to the local proxy.

E:

A drop verdict silently discards matching packets. The request is to deliver HTTP requests to the proxy, not block them.

Question 341

A firewalld administrator has tested several runtime-only rules, confirmed they are correct, and now wants to copy the active runtime configuration into the permanent configuration without re-entering each rule. Which command does that?

  1. firewall-cmd --runtime-to-permanent
  2. firewall-cmd --reload
  3. firewall-cmd --get-active-zones
  4. firewall-cmd --add-service=https
  5. ufw reload

Explanation

Correct Answer

A:

The runtime-to-permanent operation saves the active runtime firewalld configuration as its persistent configuration. Those rules can then survive a daemon reload or host reboot.

Incorrect Answers

B:

Reloading firewalld applies the already-saved permanent configuration and can discard unsaved runtime changes. It does not persist the tested runtime rules.

C:

This read-only command reports which zones are active and which interfaces or sources use them. It does not copy rule definitions into permanent storage.

D:

Without the permanent flag, add-service modifies the runtime allowance for one service. It neither copies the full runtime configuration nor commits prior changes.

E:

UFW is a different firewall configuration frontend. Reloading its rules cannot persist the active firewalld runtime configuration.

Question 342

An existing legacy script manages filter-chain rules with iptables commands. Which interface does it use?

  1. nftables
  2. ipset or nftables set
  3. iptables -A INPUT ...
  4. Conntrack state match

Explanation

Correct Answer

C:

iptables manipulates the traditional chain/rule abstraction, possibly through an nft backend on modern distributions. It is different from direct native nft syntax.

Incorrect Answers

A:

nftables is a modern Netfilter ruleset framework supporting tables, chains, sets and state matching; the evidence calls for appending a legacy-style INPUT filter rule, not merely this separate operation.

B:

Address sets allow a rule to test membership in many IP values efficiently; the task involves appending a legacy-style INPUT filter rule, whereas this addresses another subsystem.

D:

Netfilter connection tracking recognizes flows such as established and related traffic; that is not equivalent to appending a legacy-style INPUT filter rule.

Question 343

A Debian server has UFW enabled and must permit incoming TCP port 443. Which command is suitable?

  1. ufw allow 443/tcp
  2. iptables -A INPUT ...
  3. ipset or nftables set
  4. ufw status numbered
  5. nftables

Explanation

Correct Answer

A:

UFW provides a simplified frontend to host firewall rules. Allowing TCP 443 still requires the web service to listen on that port.

Incorrect Answers

B:

iptables manipulates the traditional chain/rule abstraction, possibly through an nft backend on modern distributions; that changes a different part of the system; the requested outcome is permitting inbound HTTPS with UFW.

C:

Address sets allow a rule to test membership in many IP values efficiently; this does not achieve permitting inbound HTTPS with UFW on the system described.

D:

UFW can list configured rules with stable display numbers for the current listing; it will not provide permitting inbound HTTPS with UFW under these conditions.

E:

nftables is a modern Netfilter ruleset framework supporting tables, chains, sets and state matching; using it would leave permitting inbound HTTPS with UFW unresolved.

Question 344

A shared directory should cause newly created files to inherit its group ownership under normal conditions. Which special directory bit helps?

  1. umask 027
  2. getfacl project/
  3. chmod 640 secrets.txt
  4. setgid bit on the directory

Explanation

Correct Answer

D:

A directory's setgid bit causes created entries to inherit the directory group on standard Linux filesystems. This is useful for collaboration areas.

Incorrect Answers

A:

Applying umask 027 to default file permissions 666 yields 640; the requirement is inheriting a directory's group ownership, outside the effect of this choice.

B:

getfacl displays ACL entries, including defaults when present; it does not deliver inheriting a directory's group ownership, which is decisive in this scenario.

C:

Octal 640 maps to owner rw, group r and no permission for others; the evidence calls for inheriting a directory's group ownership, not merely this separate operation.

Question 345

A support workflow requires switching to another user's login environment with that identity's password or root authorization. Which command fits?

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

Explanation

Correct Answer

C:

su - starts a login shell for the target identity and resets relevant environment values. Authentication and permissions differ from sudo delegation.

Incorrect Answers

A:

NOEXEC can prevent some dynamically linked child-process execution paths under supported conditions; that is not equivalent to changing to another user's login session context.

B:

Restricting the allowed executable and argument scope helps implement least privilege; the administrator instead needs changing to another user's login session context; this option serves a different purpose.

D:

NOPASSWD suppresses the password challenge for matched sudo commands; that changes a different part of the system; the requested outcome is changing to another user's login session context.

Question 346

An administrator wants to examine both access and default ACLs on a directory. Which command lists them?

  1. getfacl project/
  2. chattr +i settings.conf
  3. chown serviceuser:web file
  4. setuid bit on an executable

Explanation

Correct Answer

A:

getfacl displays ACL entries, including defaults when present. It helps diagnose access that ordinary ls permission bits do not fully express.

Incorrect Answers

B:

The immutable attribute blocks common changes, renames and deletion until removed by a sufficiently privileged actor; using it would leave inspecting extended file access-control entries unresolved.

C:

chown can update both user and group ownership for a file; the requirement is inspecting extended file access-control entries, outside the effect of this choice.

D:

setuid changes the effective user ID of an executed program to its file owner's ID on supported filesystems; it does not deliver inspecting extended file access-control entries, which is decisive in this scenario.

Question 347

During diagnosis, the host should log SELinux denials without actively blocking them, temporarily. Which mode fits?

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

Explanation

Correct Answer

B:

Permissive mode records would-be access denials but generally does not enforce blocking for them. It should not be mistaken for permanent policy repair.

Incorrect Answers

A:

semanage fcontext records persistent path-to-context mappings; the task involves observing denials without enforcing SELinux policy, whereas this addresses another subsystem.

C:

restorecon applies the previously configured path-based SELinux contexts to existing files; that is not equivalent to observing denials without enforcing SELinux policy.

D:

sealert analyzes SELinux denial events and suggests possible causes or remediation paths; the administrator instead needs observing denials without enforcing SELinux policy; this option serves a different purpose.

Question 348

A new file should default to no permissions for others, while allowing owner rw and group r with a usual 666 base. Which umask works?

  1. chattr +i settings.conf
  2. chmod 640 secrets.txt
  3. umask 027
  4. chown serviceuser:web file

Explanation

Correct Answer

C:

Applying umask 027 to default file permissions 666 yields 640. Directory defaults derive from 777 and become 750.

Incorrect Answers

A:

The immutable attribute blocks common changes, renames and deletion until removed by a sufficiently privileged actor; that changes a different part of the system; the requested outcome is producing secure default file permission masks.

B:

Octal 640 maps to owner rw, group r and no permission for others; this does not achieve producing secure default file permission masks on the system described.

D:

chown can update both user and group ownership for a file; using it would leave producing secure default file permission masks unresolved.

Question 349

A file currently owned by alice must become owned by serviceuser and group web. Which operation performs both?

  1. chown serviceuser:web file
  2. setgid bit on the directory
  3. getfacl project/
  4. chattr +i settings.conf
  5. setfacl -m u:bob:r-x project/

Explanation

Correct Answer

A:

chown can update both user and group ownership for a file. Membership and discretionary permissions still determine who may access it.

Incorrect Answers

B:

A directory's setgid bit causes created entries to inherit the directory group on standard Linux filesystems; the evidence calls for changing file owner and group atomically, not merely this separate operation.

C:

getfacl displays ACL entries, including defaults when present; the task involves changing file owner and group atomically, whereas this addresses another subsystem.

D:

The immutable attribute blocks common changes, renames and deletion until removed by a sufficiently privileged actor; its scope differs from changing file owner and group atomically, so it cannot meet the stated requirement.

E:

setfacl adds or modifies named access-control-list entries beyond classic owner/group/other permissions; that is not equivalent to changing file owner and group atomically.

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.

CompTIA Linux+ (XK0-006) Practice Tests