Linux+ (v7) Practice Questions
Prepare for XK0-005 with more than an answer.
Unlock the full exam and previous versions
- v1CompTIA Linux+ V8 161 questions Locked
- XK0-004Legacy CompTIA Linux+ (v6) 218 questions Locked
- XK0-005Legacy CompTIA Linux+ (v7) 279 questions Current
- Exam fee
- $390 USD
- Level
- Intermediate
- Valid for
- 3 years
Domains covered on the exam 4
- System Management32%
- Security21%
- Scripting, Containers, and Automation19%
- Troubleshooting28%
- 1
A DevOps engineer needs to write a bash script to parse an application's version from a configuration file. The version format is
version: "X.Y.Z". The script must extract only theX.Y.Zpart. Given the input lineconfig_line='version: "1.2.3-beta"', which command correctly extracts the version number?Show answer details
Correct answer: B
This command is the most direct and robust solution. It uses
cutto treat the double quote (") as a delimiter (-d '"'). The string is split into three fields:version:,1.2.3-beta, and an empty field. The-f 2option selects the second field, which is the desired version string. This method is efficient and handles variations in the version string cleanly. - 2
An administrator is hardening a new server and wants to ensure that no world-writable files exist in the
/etcdirectory, as this poses a significant security risk. Which command should be used to find all files in/etcthat have write permissions for the 'others' category?Show answer details
Correct answer: A
The
findcommand is the correct tool for this task.find /etcstarts the search in the /etc directory.-type flimits the search to regular files. The key part is-perm -o=w, which searches for files where the permission for 'others' (o) includes write (w). The hyphen (-) before the mode indicates that at least these bits must be set. - 3
A server has failed to boot, and the administrator has booted into a rescue environment. The root filesystem (
/dev/mapper/vg_root-lv_root) is suspected to have errors. Before runningfsck, the administrator must ensure the filesystem is unmounted. However,umountfails because the filesystem is busy. Which command can be used to identify and terminate all processes currently using the filesystem, allowing it to be unmounted?Show answer details
Correct answer: D
The
fusercommand is designed specifically for this purpose. The-moption indicates that the name specified is a mount point or block device, andfuserwill identify all processes using any file on that filesystem. The-koption sends aSIGKILLsignal to each of those processes, terminating them. This effectively frees up the filesystem so it can be safely unmounted for maintenance withfsck. - 4
A company policy requires that all cron jobs executed on production servers are logged with a high level of detail, including the username, command, and execution time. Which system facility should be configured in
/etc/rsyslog.confto ensure all cron-related activities are captured in a dedicated log file?Show answer details
Correct answer: D
The syslog protocol defines specific facilities to categorize log messages. The
crondaemon is assigned its own dedicated facility, namedcron. To log all messages from the cron daemon (regardless of priority), the selectorcron.*should be used in thersyslog.conffile, followed by the destination log file path (e.g.,cron.* /var/log/cron.log). - 5
A web application running on a Linux server is experiencing slow response times. A system administrator uses
ss -tlnpand notices an unusually high number of connections in theSYN-RECVstate for the web server process. What type of issue does this symptom most likely indicate?sequenceDiagram participant Client participant Server Client->>+Server: SYN Server->>-Client: SYN-ACK Note over Server: State is SYN-RECV Note over Client: Client never sends final ACKShow answer details
Correct answer: C
The
SYN-RECVstate indicates that the server has completed the first two steps of the TCP three-way handshake (it received a SYN and sent a SYN-ACK) and is waiting for the final ACK from the client. A large number of connections stuck in this state is a classic symptom of a SYN flood, a type of Denial-of-Service (DoS) attack where attackers send many SYN requests but never complete the handshake, exhausting the server's connection table. - 6
An administrator accidentally deleted the /boot/vmlinuz file and must resolve the issue before the server is rebooted. Which of the following commands should the administrator use to identify the correct version of this file?
Show answer details
Correct answer: A
- 7
A cloud engineer needs to change the secure remote login port from 22 to 49000. Which of the following files should the engineer modify to change the port number to the desired value?
Show answer details
Correct answer: D
- 8
A new file was added to a main Git repository. An administrator wants to synchronize a local copy with the contents of the main repository. Which of the following commands should the administrator use for this task? A.git reflogB.git pullC.git statusD.git push
Show answer details
Correct answer: B
- 9
A Linux administrator needs to redirect all HTTP traffic temporarily to the new proxy server 192.0.2.25 on port 3128. Which of the following commands will accomplish this task?
Show answer details
Correct answer: D
- 10
Developers have requested implementation of a persistent, static route on the application server. Packets sent over the interface eth0 to 10.0.213.5/32 should be routed via 10.0.5.1. Which of the following commands should the administrator run to achieve this goal?
Show answer details
Correct answer: D
