Courseiva

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

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

Page 2

Page 3 of 14

Page 4
151
MCQeasy

A system administrator wants to collect network performance statistics over time, including packet loss and latency, to diagnose intermittent connectivity issues. Which tool combines the functionality of ping and traceroute into a single continuous monitoring command?

A.mtr
B.tcpdump
C.ss
D.netstat
AnswerA

Correct. mtr is the tool that combines ping and traceroute with continuous monitoring.

Why this answer

mtr (My TraceRoute) continuously sends packets and displays real-time statistics including loss and latency for each hop, combining ping and traceroute.

152
MCQmedium

A Linux administrator receives reports that the system's log files are growing rapidly and consuming disk space. The administrator needs to configure the system to rotate logs weekly, keep 4 weeks of logs, compress old logs, and ensure that log rotation does not cause logs to be lost if the log file is still being written. Which configuration file and setting should be used?

A./etc/rsyslog.conf with action(type="omfile" file="/var/log/syslog" rotate="weekly" keep="4" compress)
B./etc/logrotate.d/syslog with directives: weekly, rotate 4, compress, delaycompress
C./etc/systemd/journald.conf with Settings=MaxRetentionSec=4weeks and Compress=yes
D./etc/cron.daily/logrotate script that calls logrotate -f /etc/logrotate.conf
AnswerB

logrotate is the standard tool; delaycompress ensures current log is not compressed until next rotation, preventing data loss.

Why this answer

The logrotate utility is specifically designed for log rotation, and the configuration file /etc/logrotate.d/syslog is the standard location for per-service rotation rules. The directives 'weekly', 'rotate 4', 'compress', and 'delaycompress' together achieve weekly rotation, retain 4 weeks of logs, compress old logs, and prevent data loss by delaying compression until the next rotation cycle, ensuring the log file is no longer being written to.

Exam trap

The trap here is that candidates confuse the roles of rsyslog.conf (log generation) with logrotate.conf (log rotation), or assume that systemd-journald's journal management is equivalent to traditional log file rotation, when in fact logrotate is the standard tool for rotating plain-text log files on Linux systems.

How to eliminate wrong answers

Option A is wrong because /etc/rsyslog.conf is the configuration file for the rsyslog daemon itself, which handles log generation and forwarding, not log rotation; rsyslog does not support a 'rotate' directive in its configuration syntax. Option C is wrong because /etc/systemd/journald.conf configures systemd-journald, which manages binary journal logs, not traditional text log files, and its 'MaxRetentionSec' and 'Compress' settings control journal retention and compression, not rotation of text-based log files like /var/log/syslog. Option D is wrong because while the logrotate cron job does exist at /etc/cron.daily/logrotate, simply calling 'logrotate -f' forces an immediate rotation but does not configure the rotation parameters (weekly, rotate 4, compress, delaycompress); those settings must be defined in a configuration file under /etc/logrotate.d/.

153
MCQeasy

A company uses a Linux server running a web application. Users report that they cannot access the website. The administrator checks the web server status and finds it is not running. Which command should the administrator use to view the reason for the service failure?

A.journalctl -xe
B.systemctl status httpd --full
C.tail -f /var/log/httpd/access_log
D.dmesg | grep httpd
AnswerA

Displays recent journal entries with explanations.

Why this answer

The `journalctl -xe` command displays the systemd journal log with the `-x` flag adding explanatory context and `-e` jumping to the end of the log, which is the most direct way to view the reason a systemd-managed service like httpd failed. Since the web server is managed by systemd, its failure reason (e.g., exit code, segfault, configuration error) is recorded in the journal, and this command retrieves that specific failure detail without requiring manual log file parsing.

Exam trap

The trap here is that candidates confuse the access log (option C) with the error log, or assume `systemctl status` shows the full failure reason when it only shows a truncated snippet, while `journalctl -xe` is the standard command for detailed failure diagnostics in systemd-based distributions.

How to eliminate wrong answers

Option B is wrong because `systemctl status httpd --full` shows the current status and recent log lines of the service, but it does not provide the detailed failure reason from the journal; it only truncates output lines to full width, not the cause. Option C is wrong because `tail -f /var/log/httpd/access_log` tails the HTTP access log, which records client requests, not service failure reasons; the relevant log for failures is typically `/var/log/httpd/error_log`. Option D is wrong because `dmesg | grep httpd` searches kernel ring buffer messages, which are for hardware/driver issues and kernel panics, not for user-space service failures like an httpd crash.

154
MCQhard

After a kernel update, the system boots but the network interface enp0s3 is not detected. The administrator verifies that the kernel module for the NIC is built for the new kernel. Which of the following should be done to ensure the module loads correctly?

A.Load the module with modprobe
B.Rebuild the initramfs
C.Update the udev rules
D.Reinstall the kernel package
AnswerB

Ensures the new kernel's module is available at boot.

Why this answer

After a kernel update, the initramfs (initial RAM filesystem) must be rebuilt to include the new kernel's modules. Even though the NIC module is built for the new kernel, the initramfs may still contain the old kernel's modules or lack the new module entirely, preventing it from being loaded during early boot. Running `dracut -f` (or `update-initramfs -u` on Debian-based systems) rebuilds the initramfs to match the current kernel, ensuring the NIC module is available at boot time.

Exam trap

The trap here is that candidates assume loading the module with modprobe (Option A) will fix the issue, but they overlook that the module must be available in the initramfs to be loaded during early boot before the root filesystem is accessible.

How to eliminate wrong answers

Option A is wrong because modprobe loads a module at runtime, but the issue occurs during boot before the root filesystem is mounted; the module must be present in the initramfs to be loaded early. Option C is wrong because udev rules handle device naming and permissions after the kernel has detected the hardware, but they do not cause the kernel to fail to detect the NIC; the problem is that the module is not loaded at all. Option D is wrong because reinstalling the kernel package would simply reapply the same kernel files; it does not rebuild the initramfs, which is the specific step needed to include the updated module.

155
MCQeasy

Which command displays the amount of disk space used and available on mounted filesystems in a human-readable format (e.g., GB, MB)?

A.df -h
B.lsblk
C.du -h
D.fdisk -l
AnswerA

Correct: df -h shows filesystem disk space usage in human-readable format.

Why this answer

The `df -h` command displays disk space usage for all mounted filesystems, with the `-h` flag converting raw block counts into human-readable units like GB or MB. This is the standard Linux utility for reporting filesystem capacity, usage, and available space, making it the correct choice for the question.

Exam trap

The trap here is that candidates confuse `du -h` (which shows directory-level usage) with `df -h` (which shows filesystem-level capacity), leading them to select option C when the question explicitly asks for disk space on mounted filesystems.

How to eliminate wrong answers

Option B is wrong because `lsblk` lists block devices (e.g., disks and partitions) and their attributes, but it does not show disk space usage or available capacity in human-readable format. Option C is wrong because `du -h` estimates file and directory space usage, not the total disk space used and available on mounted filesystems. Option D is wrong because `fdisk -l` displays partition table information for block devices, not current filesystem usage or available space.

156
Multi-Selecteasy

Which TWO commands display disk usage information for filesystems? (Select 2.)

Select 2 answers
A.ls
B.du
C.parted
D.df
E.fdisk
AnswersB, D

du estimates file and directory space usage.

Why this answer

The `df` command (disk free) reports the amount of available and used disk space on all mounted filesystems, while `du` (disk usage) estimates file and directory space usage. Both commands are standard tools for displaying disk usage information for filesystems in Linux.

Exam trap

A common pitfall on the CompTIA Linux+ exam is confusing filesystem usage commands (df, du) with partition management tools (fdisk, parted) or file listing commands (ls).

157
MCQmedium

An administrator views the exhibit output. Which command should be used first to investigate why sshd failed?

A.systemctl status sshd.service
B.systemctl restart sshd.service
C.journalctl -u sshd.service
D.systemctl list-units
AnswerC

Shows the service logs for diagnosis.

Why this answer

The `journalctl -u sshd.service` command is the correct first step because it displays the systemd journal logs specifically for the sshd service, providing detailed error messages and timestamps that explain why the service failed. This diagnostic approach follows the principle of checking logs before attempting to restart or modify a service, as the logs contain the root cause information needed for troubleshooting.

Exam trap

The trap here is that candidates often jump to `systemctl status` or `systemctl restart` out of habit, not realizing that the journal logs provide the specific error details needed to diagnose a failure, and that restarting without investigation can hide the root cause.

How to eliminate wrong answers

Option A is wrong because `systemctl status sshd.service` shows the current state and recent log tail, but it may not show the full historical log output needed to diagnose a failure that occurred earlier. Option B is wrong because `systemctl restart sshd.service` attempts to restart the service without first understanding why it failed, which could mask the underlying issue or cause repeated failures. Option D is wrong because `systemctl list-units` lists all loaded units and their states, but it does not provide any diagnostic details about why a specific service like sshd failed.

158
MCQhard

A Linux server that hosts a critical database application has been experiencing occasional kernel panics. The administrator wants to ensure the system automatically reboots after a panic and logs the crash dump. Which sysctl parameter should be set?

A.kernel.panic_on_warn = 10
B.kernel.panic_on_oops = 10
C.kernel.panic_print = 10
D.kernel.panic = 10
AnswerD

Sets seconds before reboot after panic.

Why this answer

Setting `kernel.panic = 10` instructs the Linux kernel to wait 10 seconds after a kernel panic before automatically rebooting. This ensures the system recovers without manual intervention, and combined with a configured crash dump mechanism (e.g., kdump), the crash dump is captured before the reboot.

Exam trap

CompTIA often tests the distinction between parameters that cause a panic (`panic_on_oops`, `panic_on_warn`) and the parameter that controls the reboot delay after a panic (`kernel.panic`), leading candidates to confuse the cause with the recovery action.

How to eliminate wrong answers

Option A is wrong because `kernel.panic_on_warn` controls whether the kernel panics on a warning (WARN()), not the reboot behavior after a panic; setting it to 10 would be invalid as it expects 0 or 1. Option B is wrong because `kernel.panic_on_oops` determines if the kernel panics on an oops (a non-fatal error), not the timeout before reboot; it also expects a boolean value (0 or 1), not 10. Option C is wrong because `kernel.panic_print` controls the verbosity of kernel messages printed during a panic, not the reboot action or delay.

159
MCQhard

An administrator is troubleshooting a web server that is not accessible from the internet. The server is running on port 80. Based on the iptables output, which of the following is the MOST likely reason?

A.The HTTP rule only allows traffic from the internal network.
B.The SSH rule is blocking HTTP traffic.
C.The loopback interface is not accepting traffic.
D.The default INPUT policy is DROP.
AnswerA

The rule for port 80 sources from 192.168.1.0/24, so internet traffic is blocked.

Why this answer

The iptables output shows an HTTP rule that explicitly matches traffic from the internal network (e.g., 192.168.1.0/24) and does not include a rule allowing HTTP traffic from external (internet) sources. Since the web server is running on port 80 but the only HTTP rule restricts source IPs to the internal subnet, traffic from the internet is not matched by any ACCEPT rule and will be subject to the default policy. This is the most likely reason the server is inaccessible from the internet.

Exam trap

CompTIA often tests the misconception that a default DROP policy is the primary cause of connectivity issues, when in fact a specific rule with an overly restrictive source or destination match is the actual problem.

How to eliminate wrong answers

Option B is wrong because SSH rules (typically port 22) do not block HTTP traffic; iptables rules are evaluated sequentially, and an SSH rule would only affect SSH packets, not HTTP packets on port 80. Option C is wrong because the loopback interface (lo) is used for local communication within the host, not for external internet traffic; its ACCEPT or DROP status does not affect inbound HTTP connections from the internet. Option D is wrong because the default INPUT policy being DROP would only apply to packets that do not match any existing rule; if the HTTP rule were correctly allowing all sources, the default policy would not block internet traffic, but here the HTTP rule itself restricts the source, so the issue is the rule's source limitation, not the default policy.

160
MCQhard

A user cannot delete a file owned by another user on a shared filesystem. The file's permissions are 644, and the directory has permissions 777 with the sticky bit set. Which action would allow the user to delete the file?

A.Change the directory's group to include the user
B.Remove the sticky bit from the directory
C.Add write permission for others on the file
D.Change the file's group to match the user's group
AnswerB

Removing the sticky bit allows users with write permission on the directory to delete any file, regardless of ownership.

Why this answer

The directory has permissions 777, meaning all users have read, write, and execute permissions. Write permission on the directory is required to delete files. However, the sticky bit prevents users from deleting files they do not own, even if they have write permission on the directory.

Removing the sticky bit (option B) removes this restriction, allowing the user to delete the file.

Exam trap

Candidates may fixate on file permissions or ownership, but deletion is governed by directory permissions. Even with write access, the sticky bit blocks deletion of other users' files. Only removing the sticky bit (B) enables deletion.

How to eliminate wrong answers

Option A is wrong because changing the directory's group to include the user does not grant the user write permission on the directory (755 gives group read+execute only) and does not override the sticky bit restriction; the user would still need directory write and the sticky bit would still block deletion. Option C is wrong because adding write permission for others on the file (chmod o+w) does not affect deletion; deletion is controlled by directory permissions and the sticky bit, not file permissions. Option D is wrong because changing the file's group to match the user's group does not give the user write permission on the directory or bypass the sticky bit; the user still cannot delete the file unless they own it or have directory write and the sticky bit is removed.

161
MCQhard

Given the Dockerfile in the exhibit, which best practice is being violated?

A.Not combining apt-get update and install in one RUN command
B.Using a non-LTS base image
C.Not using a .dockerignore file
D.Running apt-get update without cache cleanup
AnswerA

Should be combined: RUN apt-get update && apt-get install -y python3

Why this answer

The Dockerfile violates the best practice of combining `apt-get update` and `apt-get install` in a single RUN command. When these are separated, Docker caches the layer from `apt-get update`, so subsequent builds may use a stale package index, potentially installing outdated or vulnerable packages. Combining them ensures that the update and install happen atomically, reducing image size and guaranteeing a fresh package index.

Exam trap

CompTIA often tests the nuance that separating `apt-get update` and `apt-get install` is a caching and security violation, not just a style issue, and candidates may mistakenly focus on cache cleanup or .dockerignore as the primary problem.

How to eliminate wrong answers

Option B is wrong because using a non-LTS base image is not inherently a best practice violation; it may be acceptable for testing or specific requirements, and the question focuses on Dockerfile layering and caching, not base image choice. Option C is wrong because not using a .dockerignore file is a best practice for reducing build context size and preventing unintended files from being copied, but it is not the specific violation demonstrated by the given Dockerfile (which lacks combined apt commands). Option D is wrong because while running `apt-get update` without cache cleanup (e.g., `rm -rf /var/lib/apt/lists/*`) is a best practice to reduce image size, the primary violation in the exhibit is the separation of update and install into different RUN commands, not the absence of cleanup.

162
MCQeasy

Which command displays the current SELinux mode?

A.setenforce
B.selinuxenabled
C.sestatus
D.getenforce
AnswerD

getenforce shows the current SELinux mode.

Why this answer

getenforce displays whether SELinux is enforcing, permissive, or disabled.

163
MCQhard

Refer to the exhibit. A network administrator is troubleshooting a failed network connection. Based on the journalctl output, what is the most likely cause?

A.The NetworkManager service is not running.
B.The network interface eth0 is not physically connected.
C.The network configuration file has an invalid IP address.
D.The DHCP server is unreachable.
AnswerB

'No suitable device found' suggests the interface is not available or not plugged in.

164
MCQeasy

A technician needs to check the DNS A record for example.com using a specific DNS server at 8.8.8.8. Which command accomplishes this?

A.host -a example.com 8.8.8.8
B.dig -x 8.8.8.8 example.com
C.dig example.com @8.8.8.8 A
D.nslookup example.com 8.8.8.8
AnswerC

Correct syntax: dig @server name type.

Why this answer

dig @8.8.8.8 example.com A queries the specified DNS server for the A record.

165
MCQmedium

A DevOps engineer is responsible for deploying a containerized web application on a Linux server running Docker. The application consists of three services: a frontend (Nginx), a backend (Node.js), and a database (PostgreSQL). The engineer uses Docker Compose to manage the stack. The deployment works correctly on a test environment, but when deployed to production, the frontend service fails to connect to the backend. Both services are on the same custom bridge network. The engineer checks the logs of the frontend container and sees 'getaddrinfo EAI_AGAIN backend-service'. The backend service is running and healthy. The engineer suspects a DNS resolution issue within the Docker network. Which of the following is the most likely cause and correct solution?

A.The frontend container is trying to resolve 'backend-service' but the backend container's hostname is different because the container_name is set in the docker-compose.yml.
B.The containers are not on the same network because the default network driver is 'host' instead of 'bridge'.
C.The backend service is listening on a different port than expected.
D.The Docker DNS resolver is caching an old IP address for the backend service.
AnswerA

If container_name is set, the service name is not used as the hostname; the frontend should use the container_name.

Why this answer

The frontend container is attempting to resolve 'backend-service' via Docker's embedded DNS, but the backend container's hostname may differ if the `container_name` directive is set in the docker-compose.yml. Docker Compose creates a default hostname equal to the service name unless overridden by `container_name`. If `container_name` is set to something like 'my-backend', the DNS entry for 'backend-service' will not exist, causing an `EAI_AGAIN` (temporary failure in name resolution) error.

The solution is to either use the correct hostname (the service name) or set `container_name` to match the expected hostname.

Exam trap

The trap here is that candidates may assume the service name in docker-compose.yml always matches the DNS hostname, but CompTIA tests the nuance that `container_name` overrides the default hostname, causing DNS resolution failures even when containers are on the same network.

How to eliminate wrong answers

Option B is wrong because the default network driver for Docker Compose is 'bridge', not 'host'; using 'host' would bypass Docker's DNS and cause different connectivity issues. Option C is wrong because the error message 'getaddrinfo EAI_AGAIN backend-service' indicates a DNS resolution failure, not a port mismatch; a port issue would produce a connection refused or timeout error. Option D is wrong because Docker's embedded DNS resolver does not cache IP addresses in a way that would cause an `EAI_AGAIN` error; it uses a short TTL and stale entries would result in a different error (e.g., connection timeout) or a successful resolution to an old IP.

166
MCQmedium

A DevOps engineer needs to debug a bash script that unexpectedly fails when processing files. Which of the following should be added to the script to print each command before execution?

A.set -v
B.set -e
C.set -x
D.set -u
AnswerC

set -x prints commands and their arguments as they are executed.

Why this answer

set -x enables a trace of each command, printing them to stderr before execution.

167
Multi-Selecthard

An administrator needs to deploy an application stack that includes a web server and a database. The containers must be able to communicate with each other and be easily managed together. Which TWO tools or methods can accomplish this? (Select TWO.)

Select 2 answers
A.Ansible playbook with docker_container module
B.Docker Compose
C.Podman pods
D.Docker run with --link
E.Kubernetes
AnswersB, E

Docker Compose is designed for multi-container applications.

Why this answer

Docker Compose allows defining multi-container applications in a single file and manages networking and dependencies. Kubernetes orchestrates containers across a cluster. Both can manage a stack of containers with networking.

168
Multi-Selectmedium

A security administrator is reviewing SSH configuration. Which TWO settings enhance security by limiting authentication attempts and preventing password-based logins? (Choose two.)

Select 2 answers
A.MaxAuthTries 3
B.PasswordAuthentication no
C.Protocol 2
D.PermitRootLogin no
E.Port 2222
AnswersA, B

Limits number of authentication attempts.

Why this answer

MaxAuthTries sets maximum authentication attempts. PasswordAuthentication no disables password auth, forcing key-based.

169
MCQhard

A Linux administrator is troubleshooting a server that is running slowly. The 'sar -q' command shows a run queue length of 12 and a load average of 8.5. The CPU utilization is 90% idle. Which of the following is the most likely cause of the performance issue?

A.The CPU is overloaded and needs to be upgraded.
B.The network interface is saturated.
C.The system is low on memory and swapping heavily.
D.The disk I/O subsystem is a bottleneck, causing processes to wait for I/O.
AnswerD

High run queue with idle CPU typically means I/O wait; processes are in 'D' state waiting for disk.

Why this answer

The 'sar -q' output shows a high run queue length (12) and load average (8.5) despite 90% CPU idle. This indicates that processes are in an uninterruptible sleep state (D state) waiting for I/O, not contending for CPU. A disk I/O bottleneck causes processes to queue for I/O completion, inflating the load average while CPU remains idle, making D the correct answer.

Exam trap

The trap here is that candidates see a high load average and assume CPU overload, but the 90% idle CPU reveals the load is from I/O-waiting processes, not CPU contention.

How to eliminate wrong answers

Option A is wrong because CPU utilization is 90% idle, meaning the CPU is not overloaded; upgrading the CPU would not resolve I/O-bound waits. Option B is wrong because network interface saturation would manifest as high network I/O wait or dropped packets, not as a high run queue with idle CPU; 'sar -q' does not measure network congestion. Option C is wrong because low memory and heavy swapping would show high %system or %iowait due to swap I/O, but the primary symptom here is a high load average with idle CPU, which is classic for disk I/O bottlenecks, not memory pressure alone.

170
MCQmedium

A firewall administrator wants to add a rule to allow incoming SSH traffic (port 22) using firewalld. Which command correctly adds this rule to the default zone permanently?

A.firewall-cmd --add-port=22/tcp
B.firewall-cmd --add-service=ssh --permanent
C.firewall-cmd --add-port=22 --permanent
D.firewall-cmd --zone=public --add-service=ssh
AnswerB

Correct. This command adds the ssh service permanently to the default zone using the --permanent flag.

Why this answer

firewall-cmd --add-service=ssh --permanent adds the SSH service permanently. Option A lacks --permanent, Option C is missing the required protocol specification (e.g., /tcp), and Option D lacks --permanent. While --add-port=22/tcp would also work, --add-service is more descriptive and easier to manage.

171
MCQmedium

A system administrator notices that a service named 'myapp' fails to start on a Linux server. The command 'systemctl status myapp' shows 'Active: failed (Result: exit-code)'. Which of the following is the BEST first step to diagnose the issue?

A.Run 'journalctl -u myapp.service' to inspect the service logs.
B.Run 'dmesg' to view kernel messages.
C.Run 'ps aux | grep myapp' to check if the process is running.
D.Edit the service file with 'systemctl edit myapp' and increase timeout values.
AnswerA

journalctl with the unit flag shows logs for that specific service, revealing startup errors.

Why this answer

The 'journalctl -u myapp.service' command retrieves the systemd journal logs specifically for the myapp service, which contain the service's stdout, stderr, and any error messages generated during its failed startup attempt. Since the service failed with an exit code, these logs are the most direct source of diagnostic information to identify why the process terminated abnormally.

Exam trap

The trap here is that candidates often jump to checking running processes with 'ps' or kernel messages with 'dmesg', but the correct first step is always to consult the service-specific logs via 'journalctl' because systemd captures the exact failure reason from the service's own output.

How to eliminate wrong answers

Option B is wrong because 'dmesg' displays kernel ring buffer messages, which are primarily for hardware, driver, and kernel-level issues, not for application-level service failures like a process exiting with a non-zero code. Option C is wrong because 'ps aux | grep myapp' checks for currently running processes, but since the service has already failed and exited, this command will not show the failed process or provide any information about why it failed. Option D is wrong because editing the service file to increase timeout values is a premature corrective action taken without first diagnosing the root cause; the failure is due to an exit code, not a timeout, so this would not address the actual problem.

172
MCQeasy

A Linux administrator wants to ensure a Bash script exits immediately if any command fails. Which directive should be included at the beginning of the script?

A.set -o pipefail
B.set -u
C.set -e
D.set -x
AnswerC

set -e causes the script to exit if any command fails.

Why this answer

The set -e command tells the shell to exit if any command exits with a non-zero status.

173
MCQhard

A developer wants to grant a user named 'john' read and write permissions to a file, but the file currently has an ACL that gives 'jane' full control. The administrator wants to add an ACL entry for 'john' without modifying existing entries. Which command accomplishes this?

A.setfacl -x u:john:rw file
B.setfacl -b u:john:rw file
C.chmod u+rw file; setfacl -m u:john:rw file
D.setfacl -m u:john:rw file
AnswerD

Correct: -m modifies ACL, u:john:rw sets user john to rw.

Why this answer

setfacl -m adds or modifies an ACL entry without affecting others.

174
MCQhard

A DevOps team is using Ansible to manage configuration of web servers. They need to ensure that the Apache service is running and enabled at boot on all servers in the 'webservers' group. Which playbook task accomplishes this?

A.- name: Ensure Apache is running systemd: name: httpd state: started enabled: yes
B.- name: Ensure Apache is running shell: systemctl start httpd && systemctl enable httpd
C.- name: Ensure Apache is running command: systemctl enable --now httpd
D.- name: Ensure Apache is running service: name: httpd state: started enabled: yes
AnswerD

Correct. The service module with state=started and enabled=yes ensures the service is running and enabled.

Why this answer

The Ansible service module can manage services; the 'enabled' and 'state' parameters control boot status and running state.

175
MCQmedium

A Linux administrator needs to configure a firewall to allow incoming SSH connections only from the 192.168.1.0/24 subnet. The current iptables INPUT policy is ACCEPT. Which set of rules should be added?

A.iptables -A INPUT -p tcp --dport 22 -j DROP; iptables -A INPUT -p tcp --dport 22 -s 192.168.1.0/24 -j ACCEPT
B.iptables -A INPUT -p tcp --dport 22 -s 192.168.1.0/24 -j ACCEPT; iptables -A INPUT -p tcp --dport 22 -j DROP
C.iptables -A INPUT -p tcp --dport 22 -s 192.168.1.0/24 -j ACCEPT; iptables -A INPUT -p tcp --dport 22 -s 10.0.0.0/8 -j DROP
D.iptables -I INPUT -p tcp --dport 22 -j DROP; iptables -A INPUT -p tcp --dport 22 -s 192.168.1.0/24 -j ACCEPT
AnswerB

Allows allowed subnet then drops others, correct order.

Why this answer

Iptables processes rules in order, and the first matching rule determines the action. By placing the ACCEPT rule for the 192.168.1.0/24 subnet first, SSH traffic from that subnet is accepted. The subsequent DROP rule for port 22 then denies all other SSH traffic.

This ensures that only the specified subnet can connect, while the default ACCEPT policy on the INPUT chain would otherwise allow all traffic if no rule matched.

Exam trap

The trap here is that candidates often assume the order of rules doesn't matter or that a DROP rule can be placed before an ACCEPT rule for the same port, not realizing that iptables stops processing on the first match, which would drop all traffic including from the allowed subnet.

How to eliminate wrong answers

Option A is wrong because the DROP rule is added first, which would drop all incoming SSH traffic before the ACCEPT rule for 192.168.1.0/24 is evaluated, effectively blocking all SSH connections including from the allowed subnet. Option C is wrong because it only drops SSH traffic from the 10.0.0.0/8 subnet, leaving SSH traffic from all other sources (including the default ACCEPT policy) unrestricted, which does not restrict SSH to only 192.168.1.0/24. Option D is wrong because it inserts the DROP rule at the beginning of the INPUT chain using -I, which would drop all SSH traffic before the ACCEPT rule is evaluated, similar to option A, and also fails to restrict access to only the specified subnet.

176
MCQmedium

A Linux administrator needs to mount a new ext4 filesystem on /dev/sdb1 to /mnt/data. The administrator wants the filesystem to be mounted automatically at boot with noatime and with user ownership of files to be preserved (i.e., the filesystem should be owned by a specific user). Which line should be added to /etc/fstab?

A./dev/sdb1 /mnt/data ext4 defaults,noatime 0 2
B.LABEL=DATA /mnt/data ext4 noatime,user 0 2
C.UUID=xxxx /mnt/data ext4 defaults,noatime,uid=1000 0 2
D./dev/sdb1 /mnt/data ext4 rw,noatime 0 0
AnswerA

Correct because it uses 'defaults' (which preserves existing ownership) and 'noatime', and the pass value 2 allows periodic checks.

Why this answer

The 'uid=' mount option is not valid for ext4 filesystems; it is used for vfat or NTFS. For ext4, file ownership is stored on disk and preserved automatically. The correct answer is Option A: '/dev/sdb1 /mnt/data ext4 defaults,noatime 0 2'.

It uses 'defaults' which includes ownership preservation, and 'noatime' meets the requirement. The value '2' for the pass field is appropriate for non-root filesystems. Option B's 'user' option allows any user to mount, not set ownership.

Option D lacks 'noatime' and has an incorrect pass value of 0 for a filesystem that should be checked.

Exam trap

A common misconception is that the uid= mount option can be used in /etc/fstab to set ownership of the mounted filesystem. In reality, filesystem ownership is set via chown on the mount point or files, not via mount options.

How to eliminate wrong answers

Option B is wrong because the user mount option allows any user to mount the filesystem, which does not preserve user ownership of files; it also uses LABEL=DATA without ensuring the label exists, and the pass value 2 is fine but the dump value 0 is acceptable, but the core issue is the user option does not enforce ownership. Option C is wrong because uid=1000 is not a valid mount option for ext4; filesystem ownership is managed via chown or user mapping, not a mount option, and UUID=xxxx is a placeholder but the uid option is invalid. Option D is wrong because the pass value 0 means the filesystem will not be checked at boot (fsck skipped), which is not recommended for a non-root ext4 filesystem; also, it lacks the auto option explicitly, though defaults would include it, but the missing dump and pass values are incorrect.

177
MCQmedium

A user runs the ping command and receives the output shown in the exhibit. Which of the following is the MOST likely cause of the issue?

A.The destination host is down.
B.The local system does not have a default gateway configured.
C.There is a routing loop causing packets to be dropped.
D.The TTL value in the ping packet is too low.
AnswerD

TTL exceeded indicates the packet's TTL reached zero before reaching the destination.

Why this answer

The output shows 'Request timed out' or similar, which can occur when the TTL (Time to Live) value in the ping packet expires before reaching the destination. A TTL that is too low causes routers to decrement the value to zero and drop the packet, sending an ICMP Time Exceeded message back to the sender, but if the sender does not receive a reply, it indicates the packet never reached the destination. This is the most likely cause because the ping command uses a default TTL (e.g., 128 on Windows, 64 on Linux), and if the path requires more hops, the packet is silently discarded.

Exam trap

The trap here is that candidates often assume 'Request timed out' always means the destination is down, but on Linux the TTL may be set too low (default 64), and if the path requires more hops, the packet is silently discarded without any ICMP error reaching the source.

How to eliminate wrong answers

Option A is wrong because if the destination host were down, the local system would typically receive an ICMP Destination Unreachable (Host Unreachable) message from the last-hop router, not a simple timeout, unless the router also lacks a route. Option B is wrong because a missing default gateway would prevent any outbound traffic, causing all pings to fail with 'Destination host unreachable' at the local system, not a timeout after multiple hops. Option C is wrong because a routing loop causes packets to circulate indefinitely until TTL expires, which would generate ICMP Time Exceeded messages and potentially show varying TTL values in ping output, not consistent timeouts without any response.

178
MCQeasy

After a security audit, it is recommended to disable SSH password authentication in favor of key-based authentication. Which configuration line should be set in /etc/ssh/sshd_config?

A.PasswordAuthentication yes
B.PubkeyAuthentication no
C.PasswordAuthentication no
D.ChallengeResponseAuthentication yes
AnswerC

Disables password authentication, correct.

Why this answer

Disabling password authentication forces SSH to use key-based authentication, which is more secure against brute-force attacks. Setting `PasswordAuthentication no` in `/etc/ssh/sshd_config` prevents SSH from prompting for a password, requiring a valid SSH key pair for authentication. This aligns with the security audit's recommendation to disable password authentication in favor of key-based authentication.

Exam trap

The trap here is that candidates often confuse `PasswordAuthentication` with `PubkeyAuthentication` or think that disabling password authentication requires setting it to `yes`, when in fact the directive must be set to `no` to disable it.

How to eliminate wrong answers

Option A is wrong because `PasswordAuthentication yes` enables password authentication, which is the opposite of the required change to disable it. Option B is wrong because `PubkeyAuthentication no` disables public key authentication, which would prevent key-based login entirely, contradicting the goal of using key-based authentication. Option D is wrong because `ChallengeResponseAuthentication yes` enables challenge-response authentication (often used with PAM), which can still allow password-based methods and does not directly disable password authentication.

179
MCQmedium

An administrator wants to capture network traffic on interface eth0, writing the output to a file for later analysis, without resolving hostnames. Which command accomplishes this?

A.tcpdump -i eth0 -r capture.pcap
B.tcpdump -i eth0 -w capture.pcap -n
C.tcpdump -i any -w capture.pcap
D.tcpdump -n -w eth0 capture.pcap
AnswerB

This captures on eth0, writes to a file, and disables name resolution.

Why this answer

tcpdump -i eth0 -w file.pcap -n captures packets without name resolution and writes to a file.

180
MCQmedium

A security team wants to restrict SSH access to only users in the 'sshusers' group. Which configuration line in /etc/ssh/sshd_config achieves this?

A.DenyGroups sshusers
B.AllowGroups sshusers
C.AllowUsers sshusers
D.Subsystem sftp /usr/lib/openssh/sftp-server
AnswerB

Allows only members of sshusers group.

Why this answer

The `AllowGroups` directive in `/etc/ssh/sshd_config` restricts SSH login to users who are members of the specified group. By setting `AllowGroups sshusers`, only users in the 'sshusers' group are permitted to authenticate via SSH, meeting the security team's requirement.

Exam trap

The trap here is confusing `AllowGroups` with `AllowUsers`; candidates often select `AllowUsers sshusers` thinking it applies to a group, but it only matches a literal username, not group membership.

How to eliminate wrong answers

Option A is wrong because `DenyGroups sshusers` would block users in the 'sshusers' group from SSH access, which is the opposite of what is required. Option C is wrong because `AllowUsers sshusers` specifies a username, not a group; it would only allow a user literally named 'sshusers' to log in, not all members of the group. Option D is wrong because `Subsystem sftp /usr/lib/openssh/sftp-server` configures the SFTP subsystem and has no effect on restricting SSH access based on group membership.

181
MCQhard

Scenario: A financial services company runs a critical application on a Linux server that stores sensitive customer data. The server is configured with a firewall (iptables) that only allows SSH (port 22) and HTTPS (port 443) from the internal network (10.0.0.0/8). Recently, the security team detected unauthorized access attempts from an external IP address (203.0.113.5) targeting port 22. The administrator needs to block this specific IP while maintaining current access rules. The existing iptables rules are: - INPUT chain policy ACCEPT - Rule 1: -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT - Rule 2: -A INPUT -p tcp --dport 22 -s 10.0.0.0/8 -j ACCEPT - Rule 3: -A INPUT -p tcp --dport 443 -s 10.0.0.0/8 -j ACCEPT - Rule 4: -A INPUT -j DROP The administrator wants to block 203.0.113.5 from any access. Which command should be added?

A.iptables -I INPUT 1 -s 203.0.113.5 -j DROP
B.iptables -I INPUT 5 -s 203.0.113.5 -j DROP
C.iptables -A INPUT -s 203.0.113.5 -j DROP
D.iptables -I INPUT 1 -s 203.0.113.5 -j ACCEPT
AnswerA

Inserts a DROP rule at the top, blocking the IP before any ACCEPT rules.

Why this answer

Inserting the DROP rule at position 1 with `-I INPUT 1` ensures it is evaluated before the existing ESTABLISHED,RELATED rule (Rule 1). Since iptables processes rules sequentially, placing the block early prevents the malicious IP from being matched by the ESTABLISHED,RELATED rule, which would otherwise accept its packets if a related connection existed. This maintains the existing SSH and HTTPS access rules for the internal network while explicitly dropping all traffic from 203.0.113.5.

Exam trap

The trap here is that candidates often append a DROP rule with `-A` or insert it after the default DROP rule, not realizing that rules added after a final DROP are never processed, or they mistakenly use `-j ACCEPT` thinking it will override the default policy, when in fact it would allow the unwanted IP.

How to eliminate wrong answers

Option B is wrong because inserting the rule at position 5 places it after the default DROP rule (Rule 4), making it unreachable and ineffective — any packet from 203.0.113.5 would already be dropped by Rule 4 before reaching the new rule. Option C is wrong because appending with `-A` adds the rule at the end of the chain, after the default DROP rule, so it would never be evaluated and would not block the IP. Option D is wrong because it uses `-j ACCEPT` instead of `-j DROP`, which would explicitly allow all traffic from 203.0.113.5, defeating the security objective and potentially exposing the server to further attacks.

182
Multi-Selecthard

An administrator needs to capture network traffic on interface eth0 for packets destined to port 443 from host 10.0.0.1, while also writing the capture to a file for later analysis. Which three tcpdump options should be used together? (Choose three.)

Select 3 answers
A.-i eth0
B.port 443
C.-c 100
D.host 10.0.0.1
E.-n
AnswersA, B, D

Specifies the interface.

Why this answer

To capture network traffic on interface eth0 for packets destined to port 443 from host 10.0.0.1, the tcpdump options needed are -i to specify the interface, port to filter by destination port, and host to specify the source host. These three options (A, B, D) together filter the desired traffic. To write the capture to a file, the -w option is additionally required, but it is not among the answer choices.

Thus, the correct selections from the given list are A, B, and D.

183
MCQhard

Refer to the exhibit. A server administrator wants to ensure that when a user logs out, all processes started by that user are terminated. Which line should be added to the configuration?

A.IdleAction=kill
B.HandleLidSwitch=ignore
C.NAutoVTs=0
D.KillUserProcesses=yes
AnswerD

This enables termination of user processes on logout.

Why this answer

The setting 'KillUserProcesses=yes' will terminate user processes on logout. The default is 'no' as shown in the exhibit.

184
Multi-Selectmedium

A security policy requires that user passwords must expire every 60 days and users should be warned 7 days before expiration. Which two commands can be used to set these policies? (Select TWO).

Select 2 answers
A.passwd -x 60 -w 7 username
B.chage -E 60 -W 7 username
C.usermod -e 60 -f 7 username
D.chage -M 60 -W 7 username
E.passwd -n 60 -m 7 username
AnswersA, D

Correct: passwd also sets max days and warning.

Why this answer

The `passwd -x 60 -w 7 username` command sets the maximum password age to 60 days (`-x`) and the warning period to 7 days before expiration (`-w`). This directly satisfies the policy requirements for password expiration and advance warning.

Exam trap

The trap here is confusing the `chage` flags: candidates often mistake `-E` (account expiration) for password maximum age, or mix up `passwd` options like `-n` (minimum days) with `-x` (maximum days), leading them to select options that set the wrong parameters.

185
MCQmedium

A Linux server runs a web application that frequently runs out of file descriptors. Which configuration change would permanently increase the maximum number of open files for all users?

A.Set 'fs.file-max = 65536' in /etc/sysctl.conf
B.Add 'session required pam_limits.so' to /etc/pam.d/login
C.Run 'ulimit -n 65536' in a startup script
D.Edit /etc/security/limits.conf and add 'soft nofile 65536' and 'hard nofile 65536'
AnswerD

Correct file and syntax.

Why this answer

Editing /etc/security/limits.conf with both 'soft nofile' and 'hard nofile' entries permanently raises the per-user limit on open file descriptors for all users (or specified users/groups) at login. The soft limit is the current working limit, while the hard limit is the maximum ceiling; setting both ensures the user can reach the desired value without needing to run ulimit with root privileges.

Exam trap

The trap here is that candidates confuse the system-wide kernel parameter 'fs.file-max' (Option A) with the per-user PAM limits in limits.conf, assuming that raising the kernel value alone will resolve per-process file descriptor exhaustion.

How to eliminate wrong answers

Option A is wrong because 'fs.file-max' in /etc/sysctl.conf sets the system-wide kernel limit on open files, not the per-user limit; even if this is high, users are still constrained by their per-user limits from PAM. Option B is wrong because adding 'session required pam_limits.so' to /etc/pam.d/login enables PAM's limits module but does not itself set any file descriptor values; it only activates the mechanism that reads limits.conf. Option C is wrong because running 'ulimit -n 65536' in a startup script only changes the limit for the current shell session and its child processes, and it is not persistent across reboots or inherited by other users' sessions.

186
MCQeasy

Refer to the exhibit. A system administrator notices that the cleanup script runs at 2:00 AM every day but sometimes does not execute. The log shows no output from the script. Which step should be taken to investigate?

A.Verify that the script is executable by the root user.
B.Check the syslog for cron execution messages.
C.Add a MAILTO directive to the crontab.
D.Change the script to log output to a file.
AnswerD

Redirecting stdout and stderr to a file allows administrators to see error messages and diagnose failures.

Why this answer

The script runs but produces no log output, indicating it may be failing silently. Redirecting the script's stdout and stderr to a file (e.g., `>> /var/log/cleanup.log 2>&1`) captures error messages and output, allowing the administrator to see why the script sometimes does not execute or fails. This is the most direct way to diagnose a cron job that runs but yields no visible results.

Exam trap

The trap here is that candidates assume 'no output' means the script didn't run, leading them to check cron execution (Option B) or permissions (Option A), when the real issue is that the script runs but fails silently, requiring output redirection to diagnose the failure.

How to eliminate wrong answers

Option A is wrong because the script is already scheduled in root's crontab, implying it is owned and executed by root; if it were not executable, cron would typically log an error, not produce no output. Option B is wrong because checking syslog for cron execution messages would only confirm whether cron launched the job, but the problem states the script runs (the job is scheduled) yet produces no output—syslog won't reveal why the script itself fails. Option C is wrong because adding a MAILTO directive sends cron's stdout/stderr via email, but if the script produces no output (e.g., it exits silently before any echo), MAILTO will send an empty message, providing no diagnostic information about the failure.

187
MCQmedium

A technician notices a script fails to execute because the user does not have permission. The script currently has permissions 644. The technician needs to add execute permission for the owner only. Which command accomplishes this?

A.chmod a+x script.sh
B.chmod 755 script.sh
C.chmod u+x script.sh
D.chmod 744 script.sh
AnswerC

This adds execute permission for the owner only.

Why this answer

The script currently has permissions 644, meaning the owner has read/write (6), group has read (4), and others have read (4). The requirement is to add execute permission for the owner only. The command `chmod u+x script.sh` adds (+) execute (x) permission to the user (u) — the owner — without affecting group or others.

This is the precise and minimal command to achieve the goal.

Exam trap

The trap here is that candidates often confuse 'add execute for owner only' with setting permissions to 755 or using `a+x`, not realizing that `u+x` is the precise symbolic method to add execute solely for the user class without affecting group or others.

How to eliminate wrong answers

Option A is wrong because `chmod a+x script.sh` adds execute permission for all (a) — user, group, and others — which grants more permissions than required. Option B is wrong because `chmod 755 script.sh` sets permissions to rwxr-xr-x, which gives execute to owner, group, and others, not just the owner. Option D is wrong because `chmod 744 script.sh` sets permissions to rwxr--r--, which gives execute to the owner but also changes the owner's read/write permissions to read/write/execute (which is acceptable) and leaves group and others unchanged; however, it is not the minimal command (it explicitly sets all bits rather than just adding execute) and could inadvertently change other permissions if the original permissions were different, making it less precise than `chmod u+x`.

188
MCQhard

A containerized application writes logs to /var/log/app.log. The administrator wants to ensure logs persist even if the container is removed. Which approach should be used?

A.Copy logs to a bind mount
B.Set the log driver to syslog
C.Redirect logs to stdout and use docker logs
D.Use a Docker volume mounted at /var/log
AnswerD

A Docker volume is managed by Docker and persists across container removal, retaining logs.

Why this answer

Docker volumes are managed by Docker and persist independently of the container lifecycle. By mounting a volume at /var/log, the application writes logs directly to the volume, ensuring the data survives container removal and can be reused by other containers.

Exam trap

The trap here is that candidates may confuse bind mounts with Docker volumes, thinking that any host-path mapping provides automatic persistence, or they may assume that docker logs retains logs after container removal, when in fact it only works for running or stopped containers, not removed ones.

How to eliminate wrong answers

Option A is wrong because copying logs to a bind mount after they are written is not a native Docker approach; bind mounts rely on host directory paths and do not automatically persist logs if the container is removed without explicit copying. Option B is wrong because setting the log driver to syslog sends logs to the system's syslog service, but this does not guarantee persistence of the log file at /var/log/app.log within the container; it changes the output destination, not the file storage. Option C is wrong because redirecting logs to stdout and using docker logs only captures logs in the container's stdout stream, which is ephemeral and lost when the container is removed; docker logs does not provide persistent file storage.

189
MCQmedium

A DevOps engineer is writing a Bash script that checks if a file exists and is readable. Which test condition should be used inside an if statement?

A.[[ -e file ]]
B.[[ -f file ]]
C.[[ -s file ]]
D.[[ -r file ]]
AnswerD

Correct. -r returns true if the file exists and has read permission.

Why this answer

The -e test checks if a file exists, and -r checks if it is readable. Using -f also checks for a regular file, but the question requires existence and readability, so combining -e and -r is correct. However, the options include -f and -r, but -f alone does not check readability.

The correct combination is -e and -r, but since that is not an option, the best answer is -r because it implies existence? Actually, -r returns true only if the file exists and is readable. So -r alone satisfies both conditions.

190
Multi-Selecthard

Which THREE of the following are commonly used configuration management and automation tools in the Linux ecosystem? (Choose THREE.)

Select 3 answers
A.Terraform
B.Ansible
C.Salt
D.Puppet
E.Nagios
AnswersB, C, D

Agentless automation tool.

Why this answer

Ansible is a configuration management and automation tool that uses SSH for agentless communication and YAML-based playbooks to define desired system states. It is widely adopted in Linux environments for tasks such as software provisioning, configuration drift remediation, and orchestration, making it a correct choice for this question.

Exam trap

CompTIA often tests the distinction between infrastructure provisioning tools (like Terraform) and configuration management tools (like Ansible, Salt, Puppet), leading candidates to mistakenly include Terraform when the question explicitly asks for configuration management and automation tools in the Linux ecosystem.

191
MCQeasy

Which command is used to convert a file to uppercase?

A.tr '[a-z]' '[A-Z]'
B.All of the above
C.tr [:lower:] [:upper:]
D.tr a-z A-Z
AnswerB

All three options correctly convert lowercase to uppercase using tr.

Why this answer

All three commands (A, C, D) are valid ways to convert lowercase letters to uppercase using the `tr` command. Each uses a different syntax—character ranges, POSIX character classes, or bracket expressions—but all achieve the same result. The question asks which command is used, and since all options work, 'All of the above' is the correct answer.

Exam trap

CompTIA often tests the candidate's ability to recognize that multiple valid syntaxes exist for the same `tr` operation, leading them to pick a single option when 'All of the above' is the comprehensive correct answer.

How to eliminate wrong answers

Option A is wrong because it is actually a valid command, not incorrect; however, it is not the only correct one. Option C is wrong because it is also a valid command using POSIX character classes, not incorrect. Option D is wrong because it is a valid shorthand using unquoted ranges, which works in most shells, but again it is not the only correct option.

The trap is that each individual option is technically correct, so the only fully correct answer is 'All of the above'.

192
MCQeasy

A DevOps engineer is writing a Bash script to check if the configuration file /etc/myapp.conf exists and is readable. The script must exit with code 0 if the file is readable, and exit with code 1 otherwise. The script will be used on systems with Bash as the default shell. Which code snippet correctly implements this logic using the most efficient syntax available in Bash?

A.`if [ -r /etc/myapp.conf ]; then exit 0; else exit 1; fi`
B.`if test -r /etc/myapp.conf; then exit 0; else exit 1; fi`
C.`if ( -r /etc/myapp.conf ) then exit 0; else exit 1; fi`
D.`if [[ -r /etc/myapp.conf ]]; then exit 0; else exit 1; fi`
AnswerD

[[ ]] is Bash-specific, more efficient for file tests.

Why this answer

The double-bracket [[ ... ]] construct is a Bash keyword that provides enhanced test functionality, including pattern matching and more efficient parsing without word splitting or pathname expansion. It directly supports the -r operator to check if a file is readable, and the script exits 0 if true, 1 otherwise, using the most efficient syntax available in Bash.

Exam trap

The CompTIA Linux+ exam often tests the distinction between POSIX test constructs and Bash-specific enhancements, trapping candidates who assume single-bracket or test syntax is equally efficient or correct for Bash-only environments.

How to eliminate wrong answers

Option A is wrong because the single-bracket [ ... ] is a POSIX-compliant test command that invokes an external process or built-in with more overhead and is less efficient than [[ ... ]] in Bash. Option B is wrong because test is the same as single-bracket syntax, just written differently; it is not the most efficient Bash-specific syntax and still lacks the performance benefits of [[ ... ]]. Option C is wrong because ( -r /etc/myapp.conf ) uses parentheses to create a subshell, which is not a valid test construct for file readability; it will cause a syntax error or unexpected behavior.

193
MCQmedium

A Podman user wants to run a container that automatically removes itself after it stops, runs in detached mode, and maps host port 80 to container port 8080. Which command is correct?

A.podman run -rm -d -p 8080:80 nginx
B.podman run --rm -d -p 80:8080 nginx
C.podman run --remove -d -p 80:8080 nginx
D.podman run --rm -d -p 8080:80 nginx
AnswerB

Correct. Uses `--rm`, `-d`, and correct port mapping `80:8080`.

Why this answer

The correct command is podman run --rm -d -p 80:8080 nginx. Option B correctly uses --rm to automatically remove the container after it stops, -d for detached mode, and -p 80:8080 to map host port 80 to container port 8080. Option A uses an invalid flag -rm and maps ports incorrectly (8080:80).

Option C uses an invalid flag --remove. Option D maps ports incorrectly (8080:80).

194
MCQhard

A process with PID 2345 is not responding. The administrator wants to force stop the process immediately. Which command should be used?

A.kill -9 2345
B.kill -1 2345
C.pkill -15 -f processname
D.kill -15 2345
AnswerA

Correct: SIGKILL (9) forces immediate termination.

Why this answer

SIGKILL (signal 9) forcefully terminates a process. kill -9 2345 sends SIGKILL to PID 2345.

195
MCQmedium

A technician needs to search a log file for lines containing either 'ERROR' or 'FATAL' and display the line numbers. Which command accomplishes this?

A.grep -v -E 'ERROR|FATAL' logfile
B.grep -r -n 'ERROR|FATAL' logfile
C.grep -n -E 'ERROR|FATAL' logfile
D.grep -i 'ERROR|FATAL' logfile
AnswerC

Correct: -n for line numbers, -E for extended regex.

Why this answer

grep -n -E 'ERROR|FATAL' logfile uses extended regex with alternation and -n for line numbers. -i ignores case, but the stem does not mention case-insensitive; -v inverts match; -r is recursive.

196
MCQhard

A company runs a critical web application on a single Linux server. The application consists of a Node.js backend and a PostgreSQL database. The server is running out of disk space frequently due to application logs. The administrator wants to implement a log rotation solution that is automated, minimizes data loss, and compresses old logs. The administrator has root access and wants to use built-in tools. Currently, logs are written to /var/log/app/access.log and /var/log/app/error.log. The application never closes its log files. Which of the following is the best course of action?

A.Configure the systemd journal to capture the application logs and set MaxRetentionSec.
B.Create a cron job that runs every hour to move the logs to a backup directory and restart the application.
C.Configure logrotate with daily rotation, compression, and the copytruncate option.
D.Configure logrotate with a weekly rotation and no copytruncate, since the application will eventually close the log files.
AnswerC

copytruncate allows rotation of open files without restarting.

Why this answer

Logrotate with the copytruncate option allows the log file to be rotated without requiring the application to close or reopen its file handles. This is essential since the application never closes its log files. Daily rotation with compression addresses the frequent disk space issue while minimizing data loss, and logrotate is a built-in Linux tool that runs automatically via cron.

Exam trap

The trap here is that candidates may assume logrotate always requires the application to close its log files (via postrotate scripts), but the copytruncate option is specifically designed for applications that keep file handles open, making it the correct choice when the application never closes its logs.

How to eliminate wrong answers

Option A is wrong because systemd-journald is designed for capturing systemd service logs, not for rotating existing log files written directly by an application; it does not handle files like /var/log/app/access.log, and MaxRetentionSec only controls journal retention, not file rotation. Option B is wrong because moving logs and restarting the application every hour would cause unnecessary application downtime and potential data loss, and it is not a built-in automated solution like logrotate. Option D is wrong because without copytruncate, logrotate would attempt to rename or move the log file, which would cause the application to continue writing to the old file (since it never closes its file handles), leading to lost logs and no rotation; weekly rotation is also too infrequent for a server running out of disk space frequently.

197
MCQeasy

A Linux administrator wants to prevent users from reusing their last five passwords. Which PAM module should be configured?

A.pam_faillock
B.pam_pwquality
C.pam_unix
D.pam_pwhistory
AnswerD

pam_pwhistory maintains a history of previous passwords and can reject reuse.

Why this answer

The pam_pwhistory module is specifically designed to enforce password history policies by storing a user's previous passwords in a separate file (e.g., /etc/security/opasswd) and preventing reuse of those passwords. By configuring the 'remember' option in the PAM stack, the administrator can set the number of previous passwords that cannot be reused, such as 'remember=5' to block the last five passwords.

Exam trap

The trap here is that candidates often confuse pam_pwquality (which enforces password strength) with pam_pwhistory (which enforces password reuse prevention), leading them to select pam_pwquality when the question specifically asks about preventing reuse of previous passwords.

How to eliminate wrong answers

Option A is wrong because pam_faillock is used to lock user accounts after a specified number of failed login attempts, not to enforce password history or reuse restrictions. Option B is wrong because pam_pwquality is used to enforce password complexity requirements (e.g., length, character classes) and does not track or prevent reuse of previous passwords. Option C is wrong because pam_unix handles traditional Unix authentication, password updates, and shadow password management, but it does not have built-in support for password history tracking; that functionality is delegated to pam_pwhistory.

198
Multi-Selectmedium

A Linux administrator is writing a Bash script that uses a function. Which two statements about Bash functions are correct? (Choose TWO.)

Select 2 answers
A.Functions are called by their name without parentheses.
B.Functions can return a value using the return statement.
C.Function definitions must be placed at the beginning of the script.
D.Functions cannot accept arguments.
E.Functions can be called before they are defined.
AnswersA, B

Functions are invoked by name; parentheses are used only in definition.

Why this answer

Bash functions must be defined before use and are called by name without parentheses.

199
Multi-Selectmedium

A system administrator needs to monitor system performance over time. Which THREE tools can be used to collect and display CPU, memory, and I/O statistics? (Choose three.)

Select 3 answers
A.iostat
B.top
C.sar
D.vmstat
E.htop
AnswersA, C, D

Correct. iostat reports CPU utilization and input/output statistics for devices, covering CPU and I/O over time.

Why this answer

iostat reports CPU utilization and I/O statistics for devices, making it suitable for monitoring I/O and CPU over time. sar collects and displays system activity including CPU, memory, and I/O, and can log data for historical analysis. vmstat provides information about processes, memory, paging, block I/O, and CPU activity. top only shows CPU and memory per process and does not display I/O statistics, so it does not meet the full requirement. htop is similar to top and also lacks I/O statistics. Therefore, the three correct tools are iostat, sar, and vmstat.

Exam trap

CompTIA often tests the distinction between real-time interactive tools (like top and htop) and historical logging tools (like sar), and the trap here is that candidates may choose htop thinking it covers I/O, but it does not report I/O statistics, while sar is a valid tool that is sometimes overlooked.

200
MCQmedium

A Linux administrator receives reports that a web application hosted on the company's internal server is intermittently slow. The server runs CentOS 7 and hosts multiple virtual hosts. The administrator checks system resources and notices that the system's swap usage is high. Which of the following is the MOST likely cause of the performance issue?

A.Misconfigured virtual host causing memory leaks
B.Insufficient physical memory for the workload
C.Network congestion on the internal network
D.Excessive CPU load from a runaway process
AnswerB

Insufficient RAM forces the kernel to use swap, leading to high swap usage and performance degradation.

Why this answer

High swap usage indicates that the system is actively paging memory to disk because the available physical RAM is insufficient to hold the active working set. This causes significant latency because disk I/O is orders of magnitude slower than RAM, leading to intermittent slowdowns for the web application. The fact that multiple virtual hosts are running on CentOS 7 increases the memory demand, making insufficient physical memory the most likely root cause.

Exam trap

The trap here is that candidates often associate performance issues with CPU or network problems first, overlooking that high swap usage is a direct indicator of memory exhaustion, not a symptom of CPU load or network congestion.

How to eliminate wrong answers

Option A is wrong because a misconfigured virtual host causing memory leaks would manifest as steadily increasing memory consumption over time, not necessarily as high swap usage; while it could contribute, the direct symptom of high swap points to a physical memory shortage rather than a leak. Option C is wrong because network congestion would cause packet loss, retransmissions, or high latency on the network interface, not high swap usage in system memory statistics. Option D is wrong because excessive CPU load from a runaway process would be visible in CPU utilization metrics (e.g., via top or uptime), not directly in swap usage; high swap can occur with low CPU load if memory is the bottleneck.

201
MCQmedium

In a Kubernetes cluster, a developer needs to create a Deployment that runs three replicas of a container image 'myapp:1.0' and exposes port 8080. Which YAML snippet correctly defines this Deployment?

A.apiVersion: v1 kind: Pod metadata: name: myapp spec: replicas: 3 containers: - name: myapp image: myapp:1.0 ports: - containerPort: 8080
B.apiVersion: apps/v1 kind: Deployment metadata: name: myapp spec: replicas: 3 selector: app: myapp template: containers: - name: myapp image: myapp:1.0 ports: - containerPort: 8080
C.apiVersion: apps/v1 kind: Deployment metadata: name: myapp spec: replicas: 3 selector: matchLabels: app: myapp template: metadata: labels: app: myapp spec: containers: - name: myapp image: myapp:1.0 ports: - containerPort: 8080
D.apiVersion: v1 kind: Deployment metadata: name: myapp spec: replicas: 3 template: spec: containers: - name: myapp image: myapp:1.0 ports: - containerPort: 8080
AnswerC

Correct. Includes required apiVersion, selector, and template with labels.

Why this answer

A Deployment YAML must have apiVersion, kind, metadata, spec with replicas and template containing container spec with image and ports.

202
Multi-Selectmedium

Which TWO of the following are valid methods to enforce disk quota limits on a Linux filesystem? (Select TWO.)

Select 2 answers
A.Using 'edquota' to set soft and hard limits for users
B.Using 'setquota' to set limits in a script
C.Running 'repquota' to generate reports
D.Running 'quotacheck' to update quota files
E.Running 'quotaon' on the filesystem
AnswersA, E

Setting limits with edquota prepares enforcement when quotas are on.

Why this answer

'edquota' is the standard interactive command used to set soft and hard disk quota limits for users or groups on a Linux filesystem. It opens the user's quota settings in a text editor, allowing precise configuration of block and inode limits. Option E is correct because 'quotaon' is the command that enables quota enforcement on a specified filesystem, activating the quota subsystem after limits have been defined.

Exam trap

The trap here is that candidates confuse commands that set or check quotas (edquota, setquota, repquota, quotacheck) with the actual enforcement mechanism (quotaon), leading them to select multiple configuration or reporting commands instead of the one that activates enforcement.

203
MCQmedium

A development team uses Git for version control and wants to automate the testing of every commit pushed to the repository. They have a Jenkins server running on a Linux machine. The team wants to automatically trigger a Jenkins pipeline job whenever a push is made to the main branch of their Git repository. The Jenkins server is behind a firewall and cannot be accessed from the internet. The Git repository is hosted on a private GitHub repository. Which of the following is the best approach to trigger the Jenkins job automatically?

A.Have developers manually click 'Build Now' in Jenkins after each push.
B.Configure Jenkins to poll the Git repository every minute for changes.
C.Configure a GitHub webhook to send a POST request to the Jenkins server.
D.Set up a cron job on the Git server to execute a script that triggers Jenkins.
AnswerB

Works behind firewall.

Why this answer

Jenkins' polling mechanism allows it to periodically check the Git repository for changes, which works even when the Jenkins server is behind a firewall and cannot receive inbound webhooks. Polling every minute provides near-real-time automation without requiring internet access to the Jenkins server, making it the only viable option given the network constraint.

Exam trap

The trap here is that candidates assume webhooks are always the best automation trigger, but the firewall restriction makes polling the only practical solution when the Jenkins server cannot receive inbound connections.

How to eliminate wrong answers

Option A is wrong because manual triggering defeats the purpose of automation and does not scale for a development team pushing multiple commits. Option C is wrong because a GitHub webhook requires the Jenkins server to be reachable from the internet to receive the POST request, which is explicitly blocked by the firewall. Option D is wrong because the Git repository is hosted on GitHub (a cloud service), not on a local Git server; a cron job on the Git server is not possible when the server is not under the team's control.

204
MCQeasy

A Kubernetes YAML manifest defines a Deployment. Which field specifies the number of pod replicas to run?

A.metadata.replicas
B.spec.template.replicas
C.spec.containers.replicas
D.spec.replicas
AnswerD

This is the correct field to set the number of replicas.

Why this answer

In a Deployment spec, the 'replicas' field sets the desired number of pod instances.

205
MCQmedium

A Linux server running RHEL 9 has SELinux in enforcing mode. A web application (Apache) is serving content from a custom directory /var/www/html/myapp. The application needs to write to a subdirectory /var/www/html/myapp/uploads. The administrator sets the context of the uploads directory to httpd_sys_content_t and also runs `restorecon -Rv /var/www/html/myapp`. However, Apache still cannot write to the uploads directory. The administrator checks the SELinux denials in /var/log/audit/audit.log and sees AVC denials related to writing. Which step should the administrator take next?

A.Disable SELinux temporarily.
B.Set the boolean httpd_enable_homedirs to on.
C.Add the apache user to the group that owns uploads.
D.Change the type of the uploads directory to httpd_sys_rw_content_t.
AnswerD

This type allows Apache to write into the directory.

Why this answer

The httpd_sys_content_t type is for read-only content. For read-write access, the directory must have type httpd_sys_rw_content_t (or httpd_sys_script_rw_t for scripts). Setting this type via `chcon -t httpd_sys_rw_content_t /var/www/html/myapp/uploads` will allow Apache to write.

Option A (boolean httpd_enable_homedirs) is unrelated. Option C (add to group) does not address SELinux.

206
Drag & Dropmedium

Drag and drop the steps to create and apply a systemd service unit in the correct order.

Drag steps to the numbered slots on the right, or tap a step then tap a slot.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4

Why this order

The correct sequence to create and apply a systemd service unit is: create the unit file in /etc/systemd/system/, then run systemctl daemon-reload to load the new unit, then run systemctl enable to set it to start on boot, and finally run systemctl start to start it immediately. Common mistakes include enabling before reloading, starting before enabling, or attempting to enable a non-existent unit.

207
Multi-Selecthard

A system administrator needs to locate all regular files in /var/log that have been modified within the last 7 days and have a size greater than 10 MB. The administrator then needs to compress these files using gzip. Which THREE commands or options should be used together to accomplish this? (Choose THREE.)

Select 3 answers
A.find
B.locate
C.gzip
D.find /var/log -type f -mtime -7 -size +10M -exec gzip {} \;
E.xargs
AnswersA, C, D

find is the primary command used to locate files based on the specified criteria.

Why this answer

find locates files based on criteria like -type f for regular files, -mtime for modification time, -size for size. The -exec option runs a command on each file found. gzip compresses files.

208
Multi-Selecteasy

A system administrator wants to restrict SSH access to a specific group of users. Which two methods can achieve this? (Select TWO.)

Select 2 answers
A.Use /etc/security/access.conf
B.Edit /etc/ssh/sshd_config and set AllowGroups engineers
C.Modify /etc/pam.d/sshd to use pam_listfile.so
D.Add users to the sshd group
E.Edit /etc/ssh/sshd_config and set AllowUsers user1,user2,user3
AnswersB, E

The AllowGroups directive restricts SSH access to members of specified groups.

Why this answer

The `AllowGroups` directive in `/etc/ssh/sshd_config` explicitly restricts SSH access to members of specified groups. When set to `AllowGroups engineers`, only users belonging to the 'engineers' group can authenticate via SSH, providing a straightforward and secure method for group-based access control.

Exam trap

The trap here is that candidates often confuse system-level access control files (like `/etc/security/access.conf`) or PAM modules with SSH-specific directives, or mistakenly think adding users to the `sshd` group grants SSH access, when in fact `AllowGroups` and `AllowUsers` are the correct, direct methods for restricting SSH access to specific users or groups.

209
MCQeasy

A script named 'test.sh' contains '#!/bin/bash' and is located in the current directory. Which command runs the script in the current shell environment without forking a subshell?

A../test.sh
B.sh test.sh
C.bash test.sh
D.source test.sh
AnswerD

Executes in the current shell.

Why this answer

The `source` command (or its synonym `.`) executes the script in the current shell environment without forking a subshell. This is essential when you need the script to modify the current shell's environment, such as setting variables or changing directories, because a subshell would discard those changes upon exit.

Exam trap

CompTIA often tests the distinction between executing a script via its path (which forks a subshell) and sourcing it (which runs in the current shell), and candidates mistakenly think that `./test.sh` runs in the current shell because it is invoked directly from the command line.

How to eliminate wrong answers

Option A is wrong because `./test.sh` runs the script as an executable, which causes the kernel to fork a new subshell (based on the shebang) to execute the commands; the script does not run in the current shell. Option B is wrong because `sh test.sh` explicitly invokes the Bourne shell as a new process, forking a subshell that runs the script independently of the current shell. Option C is wrong because `bash test.sh` similarly launches a new Bash process as a subshell, isolating any environment changes from the parent shell.

210
MCQhard

A system administrator is configuring firewalld on a Linux server. They want to allow incoming HTTPS traffic permanently for the public zone. Which command should be used?

A.firewall-cmd --zone=public --add-service=https
B.firewall-cmd --service=https --add --zone=public --permanent
C.firewall-cmd --add-port=443/tcp --zone=public --permanent
D.firewall-cmd --add-service=https --zone=public --permanent
AnswerD

This adds the HTTPS service to the public zone permanently.

Why this answer

The `firewall-cmd --add-service=https --zone=public --permanent` command adds the HTTPS service (TCP port 443) to the public zone and makes the rule persistent across reboots. The `--permanent` flag ensures the change survives a firewall reload or system restart, and the `--zone=public` targets the correct network zone for incoming traffic.

Exam trap

The trap here is that candidates often forget the `--permanent` flag or confuse the order of arguments, leading them to choose Option A (runtime-only change) or Option B (invalid syntax), while Option C works but is not the best practice for service-based rules.

How to eliminate wrong answers

Option A is wrong because it lacks the `--permanent` flag, so the rule only applies to the runtime configuration and will be lost after a firewall reload or reboot. Option B is wrong because the syntax is invalid: `--service` is not a valid option, and the flags are in the wrong order; the correct syntax is `--add-service` followed by the service name. Option C is wrong because while it uses the correct `--permanent` and `--zone` flags, it specifies a port number instead of the service name; using the service name is preferred for clarity and ensures the correct protocol (TCP) is applied, as HTTPS always uses TCP.

211
MCQhard

A Linux administrator wants to check the history of CPU usage for the past two days using the system activity reporter. Which sar option retrieves data from the daily history file for a specific date?

A.sar -r -b
B.sar -f /var/log/sa/sa$(date +%d --date='2 days ago')
C.sar -n DEV
D.sar -u -s 00:00:00 -e 23:59:59
AnswerB

Correct: -f specifies the history file for a specific date.

Why this answer

sar -f /var/log/sa/saDD reads from the history file for a specific day (DD is the day of month).

212
MCQhard

An administrator is investigating a system that may have been compromised. The 'aide' database was created six months ago. After running 'aide --check', many files in /usr/bin are reported as changed. Which action should the administrator take first to identify the cause?

A.Increase the verbosity of AIDE to see which attributes changed.
B.Update the AIDE database with 'aide --update'.
C.Compare the checksums with the original package manager database (rpm -V).
D.Restore the original files from backup.
AnswerC

Determines if changes are from package updates or unauthorized modifications.

Why this answer

The AIDE database is six months old, so any changes to system binaries in /usr/bin since then would be flagged. The first step should be to verify whether these changes are legitimate (e.g., from package updates) or malicious by comparing the current file checksums against the RPM package manager's database using 'rpm -V'. This distinguishes expected updates from unauthorized modifications without relying on the outdated AIDE baseline.

Exam trap

The trap here is that candidates may think updating the AIDE database (Option B) is the logical next step to stop false alerts, but this would overwrite the baseline and eliminate the ability to detect the compromise, whereas the correct first action is to cross-verify with the package manager's own integrity database.

How to eliminate wrong answers

Option A is wrong because increasing AIDE verbosity only shows which attributes (e.g., permissions, size, hash) changed, but it does not help determine whether the changes are legitimate or malicious — it still compares against the same outdated database. Option B is wrong because updating the AIDE database with 'aide --update' would overwrite the old baseline with current file states, effectively accepting all changes as valid and destroying forensic evidence of potential compromise. Option D is wrong because restoring files from backup should only be done after confirming the changes are unauthorized; prematurely restoring could reintroduce vulnerabilities or overwrite evidence needed for investigation.

213
MCQeasy

A system administrator wants to deploy a containerized application on a Linux server with minimal overhead and without a daemon. Which container runtime should be used?

A.containerd
B.LXC
C.Docker
D.Podman
AnswerD

Daemonless, rootless capable.

Why this answer

Podman is the correct choice because it is a daemonless container engine that runs containers directly under the user's process space, using a fork-exec model rather than a background daemon. This aligns with the requirement for minimal overhead and no daemon, as Podman does not require a persistent service to manage containers.

Exam trap

The trap here is that candidates often associate 'container runtime' with Docker or containerd, but the question specifically tests the distinction between daemon-based and daemonless architectures, where Podman's fork-exec model is the key differentiator.

How to eliminate wrong answers

Option A is wrong because containerd is a container runtime that operates as a daemon (typically managed by systemd) and is designed to be used as a building block for higher-level tools, not as a standalone daemonless runtime. Option B is wrong because LXC (Linux Containers) is a system-level virtualization tool that creates full system containers with an init daemon, not a lightweight application container runtime, and it relies on a daemon (lxcfs or lxc-monitord) for management. Option C is wrong because Docker uses a client-server architecture with a persistent daemon (dockerd) that runs in the background, which contradicts the requirement for no daemon and adds overhead.

214
Multi-Selecthard

A Kubernetes administrator is creating a YAML manifest for a Deployment. Which three fields are required in a valid Deployment specification? (Choose three.)

Select 4 answers
A.apiVersion
B.spec
C.kind
D.status
E.metadata
AnswersA, B, C, E

Correct: apiVersion is required to specify the API version.

Why this answer

A valid Kubernetes Deployment manifest actually requires four top-level fields: apiVersion, kind, metadata, and spec. The current explanation incorrectly states that only three fields are required and that metadata is not one of them. The correct required fields are all of A, B, C, and E.

215
MCQhard

An administrator is configuring log rotation for /var/log/auth.log. They want logs to be rotated weekly, compressed, and kept for 12 weeks. Which logrotate configuration directive achieves this?

A.daily { rotate 12 compress }
B.weekly { rotate 12 compress }
C.weekly { rotate 52 compress }
D.monthly { rotate 12 compress }
AnswerB

This is the correct logrotate syntax.

Why this answer

weekly, compress, and rotate 12 set the desired behavior. The other options have incorrect parameters.

216
MCQhard

An administrator is troubleshooting a service that fails to start with a 'Permission denied' error. The administrator runs `strace -f -o /tmp/strace.log systemctl start myservice`. Which of the following best describes what this command achieves?

A.It records the kernel messages related to the service start.
B.It traces system calls for systemctl and its children, recording them to a file.
C.It monitors network connections opened by the service.
D.It traces library calls made by the service startup.
AnswerB

Correct: strace traces syscalls, -f follows forks, -o outputs to file.

Why this answer

strace traces system calls; -f follows child processes; -o writes output to file.

217
Multi-Selecthard

A system administrator is configuring a new disk partition for a database server. The disk has been partitioned as /dev/sdb1. Which three steps are necessary to make the filesystem available for use? (Choose three.)

Select 3 answers
A.Run fsck to check the filesystem
B.Mount the partition with mount
C.Add an entry to /etc/fstab
D.Create a filesystem with mkfs
E.Set a label with e2label
AnswersB, C, D

Required to attach the filesystem to the directory tree.

Why this answer

To use a new partition, you must create a filesystem (mkfs), mount it (mount), and add an entry to /etc/fstab for persistent mounting.

218
MCQhard

After modifying a PAM configuration file for sshd, a user reports they cannot log in. Which command can be used to verify the syntax of the PAM configuration without affecting running services?

A.pam_unix -t [CORRECT]
B.pam-auth-update --package [wrong]
C.pam_tally2 --check [wrong]
D.pam_faillock --test [wrong]
AnswerB

`pam-auth-update --package` is the correct command to verify PAM configuration syntax without affecting running services.

Why this answer

The `pam-auth-update --package` command is used to verify the syntax of PAM configuration files without affecting running services. It checks the configuration and reports any errors. This is the correct tool for syntax checking, whereas `pam_unix -t` does not validate syntax—it tests authentication against the pam_unix module. `pam_tally2` and `pam_faillock` are for account lockout management.

Exam trap

The trap is that candidates may think `pam_unix -t` is a syntax checker, but it is not. The appropriate command for syntax validation is `pam-auth-update --package`.

How to eliminate wrong answers

Option A is wrong because `pam_unix -t` is not a valid command; `pam_unix` is a PAM module, not a command-line tool for syntax checking. Option C is wrong because `pam_tally2 --check` is used to display login failure counts, not to verify PAM configuration syntax. Option D is wrong because `pam_faillock --test` is used to test faillock configuration for account locking, not to validate general PAM syntax.

219
MCQhard

An administrator runs 'mount -a' and receives the error shown in the exhibit. The /home partition was recently removed and replaced with a new disk. Which of the following steps should the administrator take to resolve the issue?

A.Run 'mount /dev/sda3 /home' to mount the partition manually.
B.Run 'fsck /dev/sda3' to check the filesystem.
C.Run 'mkfs.ext4 /dev/sda3' to create a new filesystem.
D.Run 'blkid /dev/sda3' to find the new UUID and update /etc/fstab.
AnswerD

blkid shows the new UUID, which can be used to replace the old UUID in fstab.

Why this answer

The error occurs because the /home partition was replaced with a new disk, so its UUID (or device identifier) in /etc/fstab no longer matches the actual disk. Running 'blkid /dev/sda3' retrieves the new UUID, which must then be updated in /etc/fstab so that 'mount -a' can mount the correct device automatically.

Exam trap

The trap here is that candidates may assume the filesystem is damaged or needs reformatting (options B or C), when in fact the error stems from a stale UUID reference in /etc/fstab after disk replacement.

How to eliminate wrong answers

Option A is wrong because manually mounting with 'mount /dev/sda3 /home' would work temporarily but does not fix the underlying fstab misconfiguration, so the error would persist on reboot. Option B is wrong because 'fsck' checks and repairs filesystem integrity, but the error here is a missing or mismatched device identifier, not a corrupt filesystem. Option C is wrong because 'mkfs.ext4' creates a new filesystem, which would destroy existing data and is unnecessary if the filesystem is already intact; the problem is purely a UUID mismatch in fstab.

220
MCQeasy

A user runs a command and receives the error 'bash: myapp: command not found'. The administrator confirms the binary exists in /usr/local/bin. Which environment variable should be checked?

A.HOME
B.SHELL
C.LD_LIBRARY_PATH
D.PATH
AnswerD

Correct. The PATH variable controls which directories the shell searches when executing commands. Adding /usr/local/bin to PATH will resolve the 'command not found' error.

Why this answer

The 'command not found' error indicates that the shell cannot locate the executable in any of the directories listed in the PATH environment variable. Even though the binary exists in /usr/local/bin, if that directory is not in PATH, the shell will not find it. Checking and correcting the PATH variable to include /usr/local/bin will resolve the issue.

Exam trap

The trap is that candidates may think HOME is responsible for sourcing profile files, but the immediate cause of 'command not found' is usually a missing or incorrect PATH. The binary exists but the shell does not search in /usr/local/bin.

How to eliminate wrong answers

Option A (HOME) is incorrect because HOME specifies the user's home directory, not the search path for executables. Option B (SHELL) is incorrect because SHELL indicates the default shell program (e.g., /bin/bash), not the directory search order. Option C (LD_LIBRARY_PATH) is incorrect because it controls the search path for shared libraries at runtime, not for executable commands.

221
MCQmedium

A cron job runs a script that fails because the command 'myapp' is not found. The script works when run manually by the same user. What is the most likely cause?

A.The user does not have a home directory
B.The cron daemon is not running
C.The script has syntax errors
D.The PATH environment variable is different
AnswerD

Cron uses a restricted PATH; the full path to 'myapp' should be specified in the crontab or script.

Why this answer

When a cron job runs, it executes with a minimal environment, typically inheriting only a limited PATH (often just /usr/bin:/bin). The 'myapp' command is not found because its location (e.g., /usr/local/bin) is not in cron's PATH. When the same user runs the script manually, their interactive shell sources profile files (like .bash_profile or .bashrc) that set a more complete PATH, including the directory containing 'myapp'.

This discrepancy is the most common cause of such failures.

Exam trap

The trap here is that candidates may assume the script has a syntax error or that the cron daemon is failing, when the real issue is the stripped-down environment (especially PATH) that cron provides, which differs from the interactive shell environment.

How to eliminate wrong answers

Option A is wrong because a missing home directory would cause other issues (e.g., cron job output not being mailed, or environment variable failures), but it does not directly prevent command resolution; cron jobs can run without a home directory. Option B is wrong because if the cron daemon were not running, the job would not execute at all, not fail with a 'command not found' error. Option C is wrong because syntax errors would cause the script to fail regardless of whether it is run manually or by cron, and the script works when run manually, ruling out syntax issues.

222
MCQhard

A Linux server experiences intermittent network connectivity issues. The administrator suspects a duplex mismatch. Which tool can best confirm duplex and speed settings on a network interface?

A.mii-tool eth0
B.dmesg | grep eth0
C.ip link show eth0
D.ethtool eth0
AnswerD

ethtool shows detailed NIC settings including negotiated speed and duplex.

Why this answer

`ethtool eth0` is the standard Linux utility for querying and controlling network interface driver and hardware settings, including negotiated speed and duplex mode. It directly displays the current link status, speed (e.g., 1000Mb/s), and duplex (full/half), making it the best tool to confirm a duplex mismatch.

Exam trap

The trap here is that candidates confuse `ip link show` (which shows link state but not speed/duplex) with `ethtool` (which provides the actual negotiated parameters), leading them to pick option C because they think 'ip' is the modern replacement for all interface queries.

How to eliminate wrong answers

Option A is wrong because `mii-tool` is a legacy utility for MII-capable interfaces and does not support modern Ethernet hardware (e.g., 1GbE or higher), often failing or returning inaccurate results on contemporary NICs. Option B is wrong because `dmesg | grep eth0` shows kernel ring buffer messages, which may include driver initialization logs but does not provide real-time, dynamic link speed or duplex information. Option C is wrong because `ip link show eth0` displays administrative and operational state (UP/DOWN) and basic flags, but it does not report negotiated speed or duplex settings; it lacks the detailed PHY-level information that `ethtool` provides.

223
MCQmedium

A system administrator notices that the /var partition is full, causing log services to malfunction. Which command should be used to quickly reclaim space by removing compressed old log files?

A.journalctl --vacuum-size=100M
B.find /var/log -type f -name '*.gz' -delete
C.rm -rf /var/log/*.gz
D.logrotate -f
AnswerB

Safely finds and deletes .gz files, reclaiming space efficiently.

Why this answer

It uses `find` to locate all files ending in `.gz` under `/var/log` and deletes them with `-delete`. Compressed old log files are typically archived with gzip, so removing them directly reclaims disk space without affecting active logs or requiring additional tools.

Exam trap

The trap here is that candidates may choose `logrotate -f` thinking it cleans up old logs, but it actually triggers rotation and compression, which can fill the partition further instead of freeing space.

How to eliminate wrong answers

Option A is wrong because `journalctl --vacuum-size=100M` only affects the systemd journal logs, not compressed old log files in `/var/log`; it reduces journal size but does not remove `.gz` files. Option C is wrong because `rm -rf /var/log/*.gz` uses a glob pattern that may fail if the file list is too long (argument list overflow) and does not handle subdirectories recursively, unlike `find`. Option D is wrong because `logrotate -f` forces a log rotation cycle, which compresses or archives current logs but does not remove already compressed old log files; it may even create new compressed files, worsening the space issue.

224
MCQhard

A Linux system experiences high CPU usage from a process that appears to be a fork bomb. The administrator wants to prevent such attacks in the future by limiting the number of processes a user can create. Which configuration file should be modified, and what parameter should be set?

A.Set 'kernel.pid_max=100' in /etc/sysctl.conf
B.Set 'DefaultLimitNPROC=100' in /etc/systemd/system.conf
C.Add 'username hard nproc 100' in /etc/security/limits.conf
D.Add 'ulimit -u 100' to /etc/profile
AnswerC

Correctly limits the number of processes for a user via PAM.

Why this answer

/etc/security/limits.conf is the PAM-based configuration file used to set per-user resource limits via the 'nproc' parameter. Adding 'username hard nproc 100' enforces a hard limit of 100 processes for that user, preventing a fork bomb from exhausting system resources.

Exam trap

CompTIA often tests the distinction between system-wide PID limits (kernel.pid_max) and per-user process limits (nproc), and candidates mistakenly choose A because they confuse maximum PID number with maximum number of processes.

How to eliminate wrong answers

Option A is wrong because 'kernel.pid_max' sets the maximum PID number, not a per-user process limit; it controls the total number of possible PIDs system-wide, not user-specific restrictions. Option B is wrong because 'DefaultLimitNPROC' in /etc/systemd/system.conf applies only to systemd-managed services, not to user login sessions or interactive shells, so it would not prevent a user-launched fork bomb. Option D is wrong because adding 'ulimit -u 100' to /etc/profile only affects interactive login shells and can be overridden by the user; it is not a persistent, system-wide enforcement mechanism.

225
Multi-Selectmedium

Which TWO commands are used to view logs in a systemd-based system? (Choose two.)

Select 2 answers
A.tail -f /var/log/messages
B.syslog
C.dmesg
D.journalctl
E.systemctl
AnswersC, D

dmesg shows kernel log messages.

Why this answer

C is correct because `dmesg` reads the kernel ring buffer, which contains boot-time and hardware-related log messages, and is commonly used to view logs on systemd-based systems. D is correct because `journalctl` is the primary command for querying and viewing logs from systemd's journal (managed by `systemd-journald`), which is the default logging subsystem in systemd-based distributions.

Exam trap

The trap here is that candidates often confuse `systemctl` (service management) with `journalctl` (log viewing) because both are systemd commands, and they may also mistakenly think `tail -f /var/log/messages` is universally available on modern systemd-based distributions.

Page 2

Page 3 of 14

Page 4