Which of the following commands should an administrator use to convert a KVM disk file to a different
format?
Show answerHide answer
Correct answer: Dqemu-img
Explanation
Explanation:
The qemu-img command is the standard QEMU/KVM utility used to create, convert, modify, and inspect virtual disk images.
Administrators commonly use it to convert disk images between formats such as:
- qcow2 (QEMU Copy-On-Write)
- raw
- vmdk (VMware)
- vdi (VirtualBox)
- vhd/vpc
Example conversion:
qemu-img convert -f qcow2 -O raw disk.qcow2 disk.raw
-f β source format -O β output format
This is exactly the tool required when working with KVM virtual machine storage.
β Why the Other Options Are Incorrect qemu-kvm:
Used to run virtual machines using KVM acceleration. It launches VMs but does not manage or convert disk images.
qemu-ng:
Not a valid standard QEMU command. Likely a distractor option.
qemu-io:
Used for low-level disk I/O testing and debugging. Helpful for performance testing or examining image behavior. Not intended for format conversion.
π§ Linux+ Exam Tip
For CompTIA Linux+:
VM disk management β think qemu-img
Running VMs β qemu-system-* / qemu-kvm
Storage conversion tasks almost always map to qemu-img.
A DevOps engineer needs to create a local Git repository. Which of the following commands should the
engineer use?
Show answerHide answer
Correct answer: Agit init
Explanation
Explanation:
The git init command is the standard way to initialize a brand-new, empty Git repository in a local directory.
Initialization:
When you run this command, Git creates a hidden subdirectory named .git that contains all the necessary metadata and skeleton files for version control tracking.
Local Workflow:
This is specifically used when starting a project from scratch on a local machine rather than downloading an existing project from a server.
Explanation of Incorrect Answers
git clone:
This command is used to copy an existing repository from a remote source (like GitHub or GitLab) to your local machine. While it results in a local repository, it is used for pre-existing projects rather than creating a new one from a local folder.
git config:
This utility is used to set configuration options, such as your username, email address, or editor preferences. It does not create or initialize a repository; it merely defines how Git behaves on your system.
git add:
The add command moves changes from the working directory to the staging area. You cannot use git add until a repository has already been initialized with git init or git clone.
Reference:
CompTIA Exam Objective: Domain 3.0 (Scripting, Containers, and Automation) β Subsection 3.3: "Explain version control concepts using Git."
Reference: Pro Git Book (Chacon & Straub); Official CompTIA Linux+ Study Guide, Chapter on Automation and Orchestration.
Question 33Choose 1
A DevOps engineer made some changes to files in a local repository. The engineer realizes that the changes
broke the application and the changes need to be reverted back. Which of the following commands is the best
way to accomplish this task?
Show answerHide answer
Correct answer: Bgit reset
Explanation
Explanation:
The engineer wants to revert changes made in a local repository because they broke the application.
The command best suited for undoing local changes and returning the repository to a previous state is: git reset
What git reset does:
Moves the current branch (HEAD) back to a previous commit.
Can unstage files or completely discard changes depending on options.
Common usage:
git reset --hard HEAD
or
git reset --hard
This restores files to a known working state.
Why the Other Options Are Incorrect
β git pull
Fetches and merges changes from a remote repository.
Does not undo local changes.
β git rebase
Rewrites commit history to apply commits onto another base.
Not intended for reverting broken local changes.
β git stash
Temporarily saves changes for later use.
Does not revert repository back to a working version.
Linux+ XK0-006 Exam Tip
Quick Git recovery mapping:
Situation β Command
Undo local commits/changes β git reset β
Temporarily save work β git stash
Update from remote β git pull
Rewrite commit history β git rebase
Exam Keyword Trigger:
If you see βrevert local changesβ β think git reset.
Question 34Choose 1
Which of the following most accurately describes a webhook?
Show answerHide answer
Correct answer: DAn HTTP-based callback function
Explanation
Explanation:
A webhook is a mechanism that allows one system to automatically send data to another system when a specific event occurs, using an HTTP request.
Instead of polling for updates, the receiving system is notified immediately.
How it works:
* Event occurs (e.g., Git push, CI/CD build completion).
* Source system sends an HTTP POST request to a predefined URL.
* Destination system processes the event data.
Example uses:
* GitHub notifying a CI/CD pipeline
* Payment systems notifying apps of transactions
* Monitoring tools sending alerts
β Why the Other Options Are Incorrect β Authentication method for web-server communication
Webhooks may use authentication, but they are not an authentication method themselves.
β SNMP-based API
SNMP is used for network monitoring, unrelated to webhooks.
β Means to transmit sensitive information
Webhooks transmit event data, not specifically sensitive information.
Security depends on implementation.
π§ Linux+ XK0-006 Exam Tip Key distinction:
Term Behavior
API polling Client repeatedly asks for updates
Webhook Server pushes event via HTTP β
π‘ Exam keyword trigger:
If you see event-driven HTTP notification, think webhook.
Question 35Choose 1
Which of the following describes PEP 8?
Show answerHide answer
Correct answer: AThe style guide for Python code
Explanation
Explanation:
PEP 8 (Python Enhancement Proposal 8) is the primary document that provides guidelines and best practices on how to write Python code.
Consistency and Readability:
The core philosophy is that "code is read much more often than it is written". PEP 8 ensures that code written by different developers looks consistent and is easy for others to maintain.
Key Guidelines:
It covers various formatting rules, including:
- Indentation: Use 4 spaces per indentation level.
- Line Length: Limit all lines to a maximum of 79 characters.
- Naming Conventions: Using snake_case for function and variable names, and PascalCase for classes.
- Whitespace: Proper use of spaces around operators and after commas.
Explanation of Incorrect Answers Python virtual environments: This refers to tools like venv or virtualenv, which allow developers to create isolated environments for different projects to avoid dependency conflicts. While PEPs exist for virtual environments (like PEP 405), PEP 8 is strictly about coding style.
A package installer for Python: The standard package installer for Python is pip. It is used to install and manage additional libraries from the Python Package Index (PyPI).
A Python variable holding octal values: In Python, octal values are represented by prefixing a number with 0o (zero and the letter "o"), such as 0o10. PEP 8 is a documentation standard, not a data type or variable.
Reference
CompTIA Exam Objective: Domain 3.0 (Scripting, Containers, and Automation) β Subsection 3.1: "Identify scripting languages and their common features" (specifically Python syntax and best practices).
Reference: Python Enhancement Proposal 8 (PEP 8) β "Style Guide for Python Code"; Official CompTIA Linux+ Study Guide, Chapter on Scripting and Automation.
Question 36Choose 1
Which of the following Ansible components contains a list of hosts and host groups?
Show answerHide answer
Correct answer: BInventory
Explanation
Explanation:
In Ansible, the inventory is the component that contains the list of hosts and host groups that Ansible manages.
The inventory can be defined in:
- A static file (commonly /etc/ansible/hosts)
- A dynamic inventory script or plugin (pulling hosts from cloud providers, CMDBs, etc.)
Hosts can be grouped into logical collections (e.g., webservers, dbservers) for targeted playbook execution.
β Why the Other Options Are Wrong
Fact: Facts are variables collected from hosts at runtime (e.g., OS version, IP address).
Playbook: Playbooks define tasks, roles, and configurations to apply to hosts, not the host list itself.
Collection: Collections are bundles of Ansible content (roles, modules, plugins), not host definitions.
π So the Ansible component that contains a list of hosts and host groups is: Inventory
Question 37Choose 1
Which of the following is a characteristic of Python 3?
Show answerHide answer
Correct answer: BIt is extensible through modules.
Explanation
Explanation:
Extensibility is one of Pythonβs core strengths and a primary reason for its popularity in system administration and automation.
Standard Library and Beyond: Python comes with a large "standard library" of pre-written code, but its true power lies in the ability to import external modules or packages.
Modular Architecture: Administrators can extend Python's functionality to perform specialized tasksβsuch as interacting with cloud APIs, managing databases, or parsing complex logsβby installing modules using tools like pip.
Code Reusability: This modularity allows developers to use existing, well-tested code instead of writing every function from scratch, which speeds up the development of automation scripts.
Explanation of Incorrect Answers
It is closed source:
Python is an open-source language managed by the Python Software Foundation (PSF). Its source code is freely available for anyone to inspect, modify, and distribute.
It is fully backwards compatible:
This is famously incorrect. One of the defining characteristics of Python 3 was that it was intentionally not fully backwards compatible with Python 2. This "clean break" was designed to fix inherent flaws in the language's design, which necessitated the long migration period known to many Linux administrators.
It is binary compatible with Java:
Python and Java are fundamentally different languages with different runtimes (Python uses an interpreter/bytecode VM, Java uses the JVM). While tools like Jython exist to run Python on the JVM, Python 3 itself is not "binary compatible" with Java.
Reference
CompTIA Exam Objective: Domain 3.0 (Scripting, Containers, and Automation) β Subsection 3.1: "Identify scripting languages and their common features".
Reference: Official CompTIA Linux+ Study Guide, Chapter on Scripting and Automation; Python.org Documentation.
Question 38Choose 1
On a Kubernetes cluster, which of the following resources should be created in order to expose a port so it is
publicly accessible on the internet?
Show answerHide answer
Correct answer: CService
Explanation
Explanation:
In Kubernetes, to expose a port so that an application becomes publicly accessible on the internet, you need to create a Service resource of the appropriate type.
Hereβs a breakdown of each option:
Deployment:
A Deployment manages Pods (replicas, rolling updates, scaling, etc.), but it does not handle networking or exposure to the outside world. Deployments define what runs, not how it's accessed from outside the cluster.
Network:
There is no core Kubernetes resource called "Network". (Network Policies exist for controlling traffic between Pods, but they restrict access β they do not expose anything publicly.)
Service: Correct.
A Service provides a stable abstraction (IP + DNS name) over a set of Pods and is the primary way to expose ports.
To make a Service publicly accessible from the internet, use one of these types:
- type: LoadBalancer β Provisions an external load balancer with a public IP (most common in cloud environments like AWS ELB, GCP, Azure).
- type: NodePort β Exposes the Service on a high port (30000β32767 range) on every node's IP address. External traffic can reach <NodePublicIP>:<NodePort>.
(ClusterIP is internal-only and does not expose to the internet.)
Pod:
Pods have IP addresses and can declare container ports, but Pods are ephemeral and their IPs are not stable or directly routable from the internet by default. Pods alone do not expose services publicly β you always need a Service (or Ingress) on top.
Question 39Choose 1
A Linux administrator wants to use AI to deploy infrastructure as code. Which of the following is a best
practice regarding the use of AI for this task?
Show answerHide answer
Correct answer: CLinting generated code
Explanation
Explanation:
When using AI to generate Infrastructure as Code (IaC), a key best practice is to validate and review the generated code before deployment.
This is especially important with AI-generated code because AI output may:
- Contain subtle errors
- Use insecure defaults
- Produce non-optimal configurations
β Ensures reliability and security before deployment.
β Why the Other Options Are Incorrect
β Using copy and paste when possible:
- Encourages unreviewed code usage.
- Increases risk of configuration errors and vulnerabilities.
- Opposite of best practice.
β Generating monolithic code:
- Monolithic IaC is harder to maintain and audit.
- Best practice is modular, reusable infrastructure code.
β Merging CI/CD pipelines:
- Pipeline structure is unrelated to safe AI usage.
- Does not validate AI-generated configurations.
π§ Linux+ Exam Tip
For AI + automation questions, CompTIA usually expects:
π Validate β Review β Lint β Test before production
Key principle:
AI assists development but does not replace verification.
Question 40Choose 1
A Linux software developer wants to use AI to optimize source code used in a commercial product. Which of
the following steps should the developer take first?
Show answerHide answer
Correct answer: BVerify that the company has a policy governing the use of AI in software development.
Explanation
Explanation:
Before using AI tools with commercial or proprietary source code, the developer must first ensure compliance with organizational security, legal, and governance policies.
Why this is critical:
- Source code may contain intellectual property (IP).
- Uploading code to external AI services may expose confidential data.
- Many organizations restrict or regulate AI usage due to:
Data privacy risks
Licensing concerns
Regulatory compliance
Security requirements
Therefore, the first step is verifying company policy to ensure AI usage is allowed and properly controlled.
β Why the Other Options Are Incorrect
β Research which AI chatbots are best:
- Tool selection comes after policy approval.
- Choosing tools without authorization could violate policy.
β Install a private LLM:
- May be a valid later solution.
- Still requires organizational approval first.
β Use open-source LLMs:
- Open source does not automatically mean compliant or approved.
- Policy and governance must come first.
π§ Linux+ Exam Tip
For AI governance questions, CompTIA emphasizes:
π Policy β Security β Validation β Implementation
If an option involves organizational policy or compliance, it is often the correct first step.
Full mock exam
Sit the XK0-006 exam before exam day
Full-length mocks with the same number of questions and the same time limit as the real XK0-006 exam. Every attempt draws a new set of questions from the full bank, so you can keep going until you pass comfortably.