Courseiva

CompTIA Linux+ (XK0-006) (XK0-006) — Questions 976979

979 questions total · 14pages · All types, answers revealed

Page 13

Page 14 of 14

976
MCQmedium

A system administrator needs to monitor file access attempts to /etc/shadow using auditd. Which auditctl command sets up the watch?

A.auditctl -a always,exit -F path=/etc/shadow -F perm=wa -k shadow_watch
B.auditctl -W /etc/shadow -p rwxa -k shadow_watch
C.auditctl -w /etc/shadow -k shadow_watch
D.auditctl -w /etc/shadow -p wa -k shadow_watch
AnswerD

Correct use of -w to watch file with write and attribute permissions.

Why this answer

The correct syntax is 'auditctl -w /etc/shadow -p wa -k shadow_watch'. The -w specifies the file, -p wa watches for write and attribute changes (access is implied), but the -k is for a key. The other options have incorrect flags or order.

977
MCQmedium

A system administrator wants to limit the CPU and memory usage of a specific service to prevent it from affecting other processes. Which Linux feature should be used?

A.ulimit
B.renice
C.cgroups
D.nice
AnswerC

cgroups can limit CPU, memory, I/O for process groups.

Why this answer

C is correct because cgroups (control groups) is the Linux kernel feature designed to limit, account for, and isolate resource usage (CPU, memory, disk I/O, etc.) of process groups. Unlike simple priority adjustments, cgroups enforce hard limits on resource consumption, making them ideal for preventing a specific service from starving other processes.

Exam trap

The trap here is that candidates confuse process priority tools (nice/renice) with resource limiting tools, not realizing that nice only affects CPU scheduling order, not hard caps on CPU or memory usage.

How to eliminate wrong answers

Option A is wrong because ulimit sets per-process resource limits (e.g., file size, number of open files) for a user session, not for a service as a whole, and it cannot limit CPU usage as a percentage or memory usage in a hierarchical manner. Option B is wrong because renice adjusts the scheduling priority (nice value) of a running process, which affects CPU time allocation but does not impose hard limits on CPU or memory usage. Option D is wrong because nice sets the initial scheduling priority of a process, influencing how the kernel allocates CPU time, but it cannot limit memory usage or enforce absolute resource caps.

978
MCQmedium

An administrator needs to add an ACL entry to a file that grants the user 'john' read and write permissions. The file currently has no ACLs. Which command should the administrator use?

A.chmod u+rw file
B.setfacl -x u:john file
C.setfacl -m u:john:rw file
D.getfacl -m u:john:rw file
AnswerC

Correctly adds or modifies ACL entry for user john with rw.

Why this answer

The correct command is setfacl -m u:john:rw file. setfacl is used to modify ACLs. getfacl is used to display ACLs and does not support a -m option for modifying ACLs on standard Linux systems.

979
Multi-Selecteasy

Which TWO of the following are valid methods for debugging a Bash script? (Choose TWO.)

Select 2 answers
A.Add 'set -r' to restrict shell
B.Run the script with 'bash -x script.sh'
C.Add 'set -x' at the start of the script
D.Run the script with 'bash -d script.sh'
E.Add 'set -n' to check syntax
AnswersB, C

Traces each command before execution.

Why this answer

Running 'bash -x script.sh' enables an execution trace that prints each command and its arguments to stderr before executing it, which is a standard debugging method for Bash scripts. Option C is correct because adding 'set -x' at the start of the script achieves the same trace output, but from within the script itself, allowing granular control over which sections are traced.

Exam trap

CompTIA often tests the distinction between syntax checking ('set -n' or 'bash -n') and runtime tracing ('set -x' or 'bash -x'), and candidates may mistakenly choose 'set -n' as a debugging method because they confuse syntax validation with execution debugging.

Page 13

Page 14 of 14