CompTIA Linux+ (XK0-006) — Questions and Answers
Question 1: Which systemd unit type is responsible for mounting filesystems during boot?
- .socket
- .service
- .mount (Correct answer)
- .path
Correct answer: .mount
.mount units correspond to filesystem mount points and are generated from /etc/fstab entries.
Question 2: What does `read -r line` do differently from `read line` in bash?
- Prevents backslash from being treated as an escape character (Correct answer)
- Reads from a file instead of stdin
- Reads the line in reverse order
- Reads only a single character
Correct answer: Prevents backslash from being treated as an escape character
The `-r` flag disables backslash interpretation, so backslashes are read literally — essential for reading file paths.
Question 3: What is the purpose of the `tcpdump` tool in Linux network security?
- Tests TCP connection speeds
- Captures and analyzes network packets in real time (Correct answer)
- Dumps network interface configuration
- Monitors TCP connection states in the kernel
Correct answer: Captures and analyzes network packets in real time
tcpdump is a packet capture tool that intercepts and displays network traffic, essential for troubleshooting and security analysis.
Question 4: Which factor MOST significantly affects the quality of technical outcomes in Linux practice?
- The brand of equipment being used
- The practitioner's training, preparation, and attention to detail (Correct answer)
- The speed at which procedures are completed
- The time of day the procedure is performed
Correct answer: The practitioner's training, preparation, and attention to detail
The quality of technical outcomes depends primarily on the practitioner's level of training, thorough preparation, and careful attention to detail. While equipment matters, the professional's competence is the most significant factor.
Question 5: Which `getopts` call correctly processes a flag `-v` and an option `-o` that takes an argument?
- getopts "v:o" opt
- getopts "v|o:" opt
- getopts "-v -o:" opt
- getopts "vo:" opt (Correct answer)
Correct answer: getopts "vo:" opt
In `getopts`, a colon after a letter means it takes an argument; `vo:` means `-v` is a flag and `-o` requires a value.
Question 6: What is the purpose of the `tune2fs` command?
- Tunes system performance by adjusting kernel parameters
- Converts ext2 to ext4 filesystem
- Adjusts tunable parameters of ext2/3/4 filesystems, such as reserved block count, check intervals, and mount options (Correct answer)
- Tunes RAID parameters for ext filesystems
Correct answer: Adjusts tunable parameters of ext2/3/4 filesystems, such as reserved block count, check intervals, and mount options
tune2fs modifies ext2/3/4 filesystem parameters without reformatting, including reserved space percentage, mount count limits, and filesystem features.
Question 7: What does `ls -d */` display?
- Symbolic links only
- All files including hidden ones
- Files sorted by directory
- Only directories in the current location (Correct answer)
Correct answer: Only directories in the current location
`ls -d */` matches and lists only directories (the trailing slash selects directories, `-d` prevents recursion).
Question 8: What role does calibration play in maintaining technical accuracy for Linux professionals?
- It is only necessary for new equipment
- It is an optional best practice for advanced professionals
- It only matters during formal inspections
- It ensures instruments and methods produce accurate, consistent results over time (Correct answer)
Correct answer: It ensures instruments and methods produce accurate, consistent results over time
Regular calibration ensures that instruments, tools, and methods continue to produce accurate and consistent results over time. Without calibration, measurement drift and equipment wear can lead to unreliable outcomes.
Question 9: In Linux practice, what is the CORRECT sequence when performing a technical procedure?
- Document, execute, then plan
- Execute, then plan and review
- Plan, prepare, execute, verify, and document (Correct answer)
- Execute immediately and document only if issues arise
Correct answer: Plan, prepare, execute, verify, and document
The correct sequence follows a systematic approach: plan the procedure, prepare necessary resources, execute according to standards, verify results meet specifications, and document the process and outcomes. This ensures quality and accountability.
Question 10: Which command installs and activates fail2ban to protect SSH from brute-force attacks?
- fail2ban-client start sshd
- systemctl enable --now fail2ban (Correct answer)
- service fail2ban install && start
- apt install fail2ban --activate-ssh
Correct answer: systemctl enable --now fail2ban
After installing fail2ban, systemctl enable --now fail2ban starts the service immediately and enables it at boot.
Question 11: When a Linux professional faces pressure to compromise professional standards, the BEST response is to:
- Immediately resign from the position
- Document the pressure and uphold professional standards (Correct answer)
- Ignore the pressure and continue without reporting
- Comply to maintain workplace relationships
Correct answer: Document the pressure and uphold professional standards
Professionals should document any pressure to compromise standards and continue upholding their professional obligations. Documentation creates a record of the situation while maintaining ethical integrity.
Question 12: What does `set -u` do in a bash script?
- Enables Unicode support
- Updates the PATH variable
- Treats unset variables as an error when they are expanded (Correct answer)
- Unsets all variables
Correct answer: Treats unset variables as an error when they are expanded
`set -u` causes the script to exit with an error if an unset variable is referenced, catching typos early.
Question 13: In SELinux, what does the 'enforcing' mode do to policy violations?
- Only logs to audit.log without blocking
- Blocks and logs violations (Correct answer)
- Disables all network policies
- Logs violations but allows them
Correct answer: Blocks and logs violations
Enforcing mode actively blocks actions that violate SELinux policy and records denials in the audit log.
Question 14: In Linux certification, what does redundancy in system design primarily provide?
- Increased complexity
- Simplified maintenance
- Fault tolerance and high availability (Correct answer)
- Lower initial cost
Correct answer: Fault tolerance and high availability
Redundancy provides fault tolerance by ensuring that if one component fails, backup components maintain system availability.
Question 15: Which command displays the process tree showing parent-child relationships?
- procstat
- pstree (Correct answer)
- top -H
- ps -ef
Correct answer: pstree
pstree displays running processes as a tree, visually showing parent-child relationships between processes.
Question 16: What role does calibration play in maintaining technical accuracy for Linux professionals?
- It ensures instruments and methods produce accurate, consistent results over time (Correct answer)
- It is an optional best practice for advanced professionals
- It is only necessary for new equipment
- It only matters during formal inspections
Correct answer: It ensures instruments and methods produce accurate, consistent results over time
Regular calibration ensures that instruments, tools, and methods continue to produce accurate and consistent results over time. Without calibration, measurement drift and equipment wear can lead to unreliable outcomes.
Question 17: Which option makes `apt-get` automatically remove packages that were installed as dependencies but are no longer needed?
- apt-get remove --auto
- apt-get clean
- apt-get purge --orphans
- apt-get autoremove (Correct answer)
Correct answer: apt-get autoremove
`apt-get autoremove` removes orphaned dependency packages that are no longer required by any installed package.
Question 18: How do you append a line to a file inside a shell script without overwriting it?
- echo 'line' > file
- echo 'line' | file
- echo 'line' >> file (Correct answer)
- echo 'line' >| file
Correct answer: echo 'line' >> file
`>>` appends to a file; `>` truncates and overwrites.
Question 19: What does the 'umask 027' command do?
- Sets the maximum permission to 027
- Removes all permissions from new files
- Makes all new files executable
- New files get permissions 640 and new directories get 750 (Correct answer)
Correct answer: New files get permissions 640 and new directories get 750
umask 027 masks out write for group and all permissions for others, resulting in 640 for files and 750 for directories.
Question 20: When a Linux professional encounters an unexpected result during a technical procedure, the FIRST action should be to:
- Continue the procedure and address it later
- Repeat the procedure from the beginning immediately
- Report the issue without any preliminary assessment
- Stop, assess the situation, and determine whether to proceed or seek guidance (Correct answer)
Correct answer: Stop, assess the situation, and determine whether to proceed or seek guidance
Stopping to assess the situation when unexpected results occur is critical. This allows the professional to evaluate whether it is safe and appropriate to continue, and to determine if additional guidance or resources are needed.
Question 21: What does 'find / -perm -4000' search for?
- Files readable by all users
- Files with the SUID bit set (Correct answer)
- World-writable files
- Files owned by root
Correct answer: Files with the SUID bit set
-perm -4000 matches files where the SUID bit (4000) is set, which can be a privilege escalation risk.
Question 22: Which boot parameter disables all CPU mitigations for Spectre/Meltdown vulnerabilities, sometimes used for performance testing?
- cpu.mitigations=none
- nosecurity=1
- mitigations=off (Correct answer)
- nopti nospectre_v2
Correct answer: mitigations=off
The mitigations=off kernel parameter is a single flag that disables all CPU vulnerability mitigations (available since Linux 5.2).
Question 23: Which nmap flag performs a SYN (stealth) scan without completing the TCP handshake?
- -sS (Correct answer)
- -sT
- -sA
- -sU
Correct answer: -sS
nmap -sS sends SYN packets and never completes the handshake, making the scan less likely to appear in connection logs.
Question 24: In Linux, what is the PRIMARY purpose of conducting regular safety drills and exercises?
- To ensure personnel can respond effectively in emergencies (Correct answer)
- To evaluate employee performance reviews
- To satisfy insurance requirements only
- To reduce daily workload
Correct answer: To ensure personnel can respond effectively in emergencies
Regular safety drills ensure that all personnel are prepared to respond effectively during actual emergencies. Practice builds muscle memory, identifies gaps in emergency procedures, and improves overall response times.
Question 25: Which iptables table is used for Network Address Translation (NAT)?
- mangle
- filter
- nat (Correct answer)
- raw
Correct answer: nat
The nat table handles NAT operations including SNAT, DNAT, and MASQUERADE in the PREROUTING and POSTROUTING chains.
Question 26: In nftables, what keyword is used to create a stateful firewall rule accepting established and related traffic?
- ct state { established, related } accept (Correct answer)
- match state established related permit
- conntrack state=ESTABLISHED,RELATED -j ACCEPT
- state established,related ACCEPT
Correct answer: ct state { established, related } accept
nftables uses 'ct state' (connection tracking state) with set notation to match multiple states in one expression.
Question 27: When a Linux professional encounters an unexpected result during a technical procedure, the FIRST action should be to:
- Report the issue without any preliminary assessment
- Repeat the procedure from the beginning immediately
- Stop, assess the situation, and determine whether to proceed or seek guidance (Correct answer)
- Continue the procedure and address it later
Correct answer: Stop, assess the situation, and determine whether to proceed or seek guidance
Stopping to assess the situation when unexpected results occur is critical. This allows the professional to evaluate whether it is safe and appropriate to continue, and to determine if additional guidance or resources are needed.
Question 28: What does `$(command)` do in a shell script?
- Pipes command output to /dev/null
- Captures the command's stdout as a string (Correct answer)
- Executes the command in the background
- Runs the command in a subshell and discards output
Correct answer: Captures the command's stdout as a string
Command substitution `$(...)` replaces itself with the standard output of the enclosed command.
Question 29: What is the purpose of the UFW (Uncomplicated Firewall) command `ufw enable`?
- Reloads the firewall rules without enabling it
- Activates the firewall and enables it to start on boot (Correct answer)
- Only enables the firewall for the current session
- Creates a default allow-all policy
Correct answer: Activates the firewall and enables it to start on boot
ufw enable both activates the firewall immediately and configures it to start automatically on system boot.
Question 30: What is the purpose of the /etc/sudoers file?
- Store hashed passwords for sudo users
- Define which users can run commands as root or another user (Correct answer)
- Log all sudo command executions
- Set password expiration policies
Correct answer: Define which users can run commands as root or another user
/etc/sudoers specifies user and group privileges for running commands via sudo.
CompTIA Linux+ (XK0-006)
CompTIA Linux+ certifies foundational Linux administration skills for IT professionals, covering system management, security, scripting/automation, and troubleshooting of Linux-based environments.
Exam Rules
- You can skip questions and return to them later
- Flag questions for review before submitting
- No feedback shown until you submit the entire exam
- Unanswered questions count as wrong — answer everything
- 10 pretest questions are mixed in and don't affect your score
- Timer auto-submits when time runs out
- Your progress is auto-saved every 30 seconds