CompTIA Linux+ · Domain 4 of 5

CompTIA Linux+ Domain 4: Automation, Orchestration, and Scripting

This domain moves from typing commands to writing them down: Bash scripts, infrastructure as code, CI/CD, container orchestration, Python basics, Git and the responsible use of AI tools. Questions test whether you can read code and pick the right tool for the scale.

Exam weight
17%
Official objectives
5
Estimated questions estimate
~15
Suggested study time estimate
15–25 hrs

About 18 min read Reviewed October 2026

Overview

Automation, Orchestration, and Scripting is 17% of the XK0-006 exam across five objectives. Objective 4.1 surveys infrastructure as code with Ansible, Puppet and OpenTofu, unattended deployment with Kickstart and cloud-init, CI/CD ideas such as shift-left testing, GitOps and DevSecOps, and orchestration with Kubernetes, Docker Swarm and Compose. Objective 4.2 is hands-on Bash: expansion, functions, conditionals, loops, comparisons, tests and return codes. Objectives 4.3 to 4.5 cover Python basics for administrators, version control with Git, and best practices for using AI tools safely.

The domain exists because modern Linux administration is repeatable and reviewable rather than manual. It takes the tasks from Domains 1 and 2, such as creating users, installing packages and starting services, and expresses them as code that can be versioned, tested and run across many servers at once.

How it's tested

Expect two styles. Summarize objectives (4.1, 4.3, 4.5) ask which tool, concept or practice fits a situation, such as agentless configuration management or where to store a database password in Kubernetes. Scenario objectives (4.2, 4.4) show a script or Git situation and ask what the code does, why it fails, or which command achieves the goal.

  • Read the snippet

    A short Bash script or Python fragment is shown and you predict its output, find the bug, or choose the line that completes it.

  • Match tool to architecture

    Requirements such as no agents, declarative cloud resources, or first-boot configuration point to Ansible, OpenTofu or cloud-init respectively.

  • Safe version control

    A Git situation, such as uncommitted work, a messy feature branch or a shared branch, asks for the command that achieves the goal without losing work or rewriting others' history.

Reasoning it through

A team must apply the same sshd settings to 200 existing servers, and security will not allow new agents to be installed. Puppet's usual model needs an agent and certificate signing on each node, and Kickstart only applies at installation time. Ansible connects over SSH with no agent and its modules are idempotent, so rerunning the playbook changes only servers that drift. That makes Ansible the fit for the stated constraints.

Objectives 5

Official objectives from the CompTIA outline, in outline order.

4.1 Summarize the use cases and techniques of automation and orchestration in a Linux environment.Infrastructure as code, unattended deployment, CI/CD and container orchestration.
What it means
Covers Ansible (playbooks, inventory, modules, ad hoc commands, collections, facts, agentless operation), Puppet (classes, modules, facts, certificates), OpenTofu (providers, resources, state), unattended installs with Kickstart and cloud-init, CI/CD concepts (pipelines, shift-left testing, GitOps, DevSecOps), and orchestration with Kubernetes objects, Docker Swarm and Docker or Podman Compose.
What to understand
Configuration management tools such as Ansible and Puppet shape the inside of servers, while OpenTofu declares infrastructure through provider APIs and records it in a state file. Kickstart answers installer questions; cloud-init configures a cloud instance at first boot. In Kubernetes, a Deployment keeps the desired number of Pods running, a Service gives them a stable address, ConfigMaps hold settings and Secrets hold sensitive values.
How it shows up
A requirement names a constraint, such as no agents, provisioning cloud resources declaratively, first-boot configuration of instances, or keeping three replicas running, and you choose the tool or object that fits.
Common confusion
Treating Kubernetes Secrets as encrypted. By default their values are only base64-encoded, so access control and encryption at rest still matter.
4.2 Given a scenario, perform automated tasks using shell scripting.Bash expansion, functions, conditionals, loops, comparisons, tests and exit codes.
What it means
Covers parameter expansion (${var}), command substitution ($(cmd) and backticks), subshells, functions, the interpreter line (#!), IFS, if, case, for, while and until, numeric comparisons (-eq, -ne, -lt, -le, -gt, -ge), string comparisons and regex matching with [[ =~ ]], file and string tests (-f, -d, -z, -n, !), variables, export, local, set and unset, and return codes in $?.
What to understand
Numeric and string comparisons are different operators: -gt compares integers, while > inside [[ ]] compares text in sort order, so "100" > "89" is false. Exit status 0 means success, and $? holds only the most recent command's status. Unquoted variables split on whitespace, which breaks file names with spaces.
How it shows up
A script snippet misbehaves on certain input, or you choose the test that checks a directory exists, a variable is empty, or a value exceeds a threshold.
Common confusion
Using = or > for numbers. They perform string comparison and can give wrong answers for values with different digit counts.
4.3 Summarize Python basics used for Linux system administration.Virtual environments, modules, dependencies, data types and PEP 8 style.
What it means
Covers creating and activating virtual environments, using built-in modules, installing dependencies, the core data types (Boolean, integer, floating point, string, list, dictionary), importing modules and packages, significant indentation and the PEP 8 style guide.
What to understand
A virtual environment created with python3 -m venv isolates a project's packages from the system Python, so installs do not break distribution tools that depend on system packages. Indentation defines code blocks, so mixed or inconsistent indentation is a syntax error, not a style issue. Dictionaries map keys to values; lists keep ordered items.
How it shows up
A script fails with an import error when run outside its environment, pip refuses to install system-wide, or you identify which data type fits structured data such as hostnames mapped to IP addresses.
Common confusion
Running sudo pip install to fix a missing module. It risks conflicts with distribution-managed packages; a virtual environment is the intended approach.
4.4 Given a scenario, implement version control using Git.Core Git commands, branching, merging, rebasing, stashing, tags and .gitignore.
What it means
Covers init, clone, config, add, commit, status-style inspection with diff and log, branch and checkout, fetch, pull and push, merge including squash merges, rebase, reset, stash, tag and excluding files with .gitignore.
What to understand
fetch downloads remote changes without touching your working branch; pull is fetch plus merge (or rebase). stash shelves uncommitted work so you can switch branches. rebase rewrites commits onto a new base, which is fine locally but disruptive on branches others have pulled. .gitignore only affects untracked files; a file already committed must be removed from the index with git rm --cached.
How it shows up
You need to switch branches with uncommitted changes, combine a noisy feature branch into one commit (merge --squash), mark a release (tag), or stop tracking a secrets file that was committed.
Common confusion
Thinking reset --hard is a safe undo. It discards uncommitted changes in the working tree permanently.
4.5 Summarize best practices and responsible uses of artificial intelligence (AI).AI use cases for administrators, output verification, data governance and policy.
What it means
Covers using AI tools to generate code, regular expressions and infrastructure as code, write documentation, suggest compliance settings, review security, optimise and lint code, and the practices around them: reviewing and verifying output, data governance (data security, whether prompts train a model, human review, local versus public models), following corporate policy and prompt engineering.
What to understand
AI output is a draft that must be read, tested and validated before it runs on production systems, because it can be plausible but wrong. Pasting secrets, customer data or proprietary code into a public model may expose it or let it be used for training; a locally hosted model or an approved enterprise service keeps data under control.
How it shows up
An administrator wants to use an AI assistant on a configuration that contains credentials, or to run a generated script directly on servers, and you pick the responsible practice.
Common confusion
Assuming AI-generated code is safe because it runs without errors. Running is not the same as doing the right thing securely.

High-yield concepts

The terms, rules and formulas this domain turns into questions most often.

  • Idempotency

    An idempotent task produces the same end state no matter how many times it runs, changing only what differs from the desired state.

    Remember
    Ansible modules and declarative tools are designed to be idempotent; ad hoc shell commands often are not.
    Tested as
    Explains why configuration management is preferred over looping SSH scripts.
    Trap
    Using an Ansible shell module for tasks a purpose-built module handles idempotently.
  • Ansible architecture

    Ansible pushes tasks from a control node over SSH to hosts listed in an inventory, using YAML playbooks of modules and gathering system facts first.

    Remember
    Agentless; managed nodes need SSH and Python, not an installed agent.
    Tested as
    Tool-choice questions that mention no agents or SSH-only access.
    Trap
    Confusing Ansible's push model with Puppet's typical agent pull model.
  • OpenTofu state

    OpenTofu, an open-source infrastructure-as-code tool, declares resources through providers and keeps a state file mapping its configuration to real resources so it can plan changes.

    Remember
    Losing or hand-editing state can cause duplicate or orphaned resources; store it securely and share it carefully.
    Tested as
    Infrastructure provisioning and drift questions.
    Trap
    Treating OpenTofu as a tool for configuring software inside an existing server.
  • Kickstart versus cloud-init

    Kickstart supplies answers to the RHEL-family installer for unattended installs, while cloud-init applies user data, such as users, keys, packages and scripts, when a cloud image first boots.

    Remember
    Kickstart is install time; cloud-init is first boot of a prebuilt image.
    Tested as
    Unattended deployment scenarios on bare metal versus cloud.
    Trap
    Choosing Kickstart for configuring cloud instances launched from images.
  • Kubernetes core objects

    A Pod runs one or more containers, a Deployment maintains a set number of Pod replicas and rolling updates, a Service gives Pods a stable network endpoint, and ConfigMaps and Secrets inject configuration.

    Remember
    Pods are disposable; Deployments recreate them.
    Tested as
    Matching an object to a requirement such as scaling or stable addressing.
    Trap
    Exposing an application by Pod IP instead of a Service.
  • GitOps and shift-left

    GitOps treats a Git repository as the source of truth for system state, with automation reconciling systems to match it, while shift-left testing moves testing and security checks earlier in the pipeline.

    Remember
    In GitOps, changes go through commits and reviews, not direct edits on servers.
    Tested as
    CI/CD concept questions in objective 4.1.
    Trap
    Fixing production by hand in a GitOps environment, which the next sync reverts.
  • Numeric versus string comparison

    -eq, -ne, -lt, -le, -gt and -ge compare integers, while =, ==, !=, < and > compare strings in sort order.

    Remember
    Inside [[ ]], > is a string comparison, so 100 compares as less than 89.
    Tested as
    Script bug questions about thresholds.
    Trap
    Using > to compare disk usage percentages.
  • Exit codes and $?

    Every command returns a status, 0 for success and non-zero for failure, and $? holds the status of the last command that ran.

    Remember
    Check $? immediately or capture it in a variable; any later command overwrites it.
    Tested as
    Error handling and conditional flow in scripts.
    Trap
    Running echo before testing $?, which then reports echo's success.
  • Quoting and expansion

    Double quotes allow variable and command expansion but prevent word splitting, while single quotes prevent all expansion.

    Remember
    Quote variables ("$file") so names with spaces stay one argument; prefer $(cmd) over backticks.
    Tested as
    Scripts that fail only on some file names.
    Trap
    Expecting '$HOME' in single quotes to expand.
  • local and export

    local limits a variable to the function where it is declared, while export copies a variable into the environment of child processes started afterwards.

    Remember
    A child script cannot change its parent's variables.
    Tested as
    Variable scope bugs in functions and called scripts.
    Trap
    Expecting a variable set in a called script to appear in the calling shell.
  • Python virtual environment

    python3 -m venv creates an isolated directory with its own interpreter link and site-packages, activated with source venv/bin/activate.

    Remember
    Install project dependencies inside the venv, usually from a requirements file.
    Tested as
    Dependency and module import scenarios.
    Trap
    Using sudo pip to install into the system Python.
  • git fetch versus git pull

    fetch downloads new commits from the remote into tracking branches without changing your work, while pull fetches and then merges or rebases them into the current branch.

    Remember
    Use fetch to inspect incoming changes safely before integrating.
    Tested as
    Collaboration scenarios with remote changes.
    Trap
    Assuming fetch updates the files in your working directory.
  • merge, squash and rebase

    merge joins histories with a merge commit, merge --squash stages all branch changes for one new commit, and rebase replays commits on top of another base, rewriting their IDs.

    Remember
    Do not rebase commits that others have already pulled.
    Tested as
    Choosing how to integrate a feature branch.
    Trap
    Rebasing a shared branch and forcing everyone to reconcile rewritten history.
  • AI data governance

    Prompts sent to a public AI service may be stored or used for training, so sensitive data, credentials and proprietary code require an approved or locally hosted model and adherence to corporate policy.

    Remember
    Verify and review AI output before use; a human remains accountable.
    Tested as
    Responsible-use questions in objective 4.5.
    Trap
    Pasting a configuration with live credentials into a public chatbot.

Side by side

Concepts candidates mix up, compared on the point that decides the answer.

Ansible vs. Puppet vs. OpenTofu

ConceptMeaningKey differenceCommon trap
Ansible Configuration management with YAML playbooks Agentless push over SSH Thinking an agent must be installed first
Puppet Declarative configuration management with classes and modules Typically an agent that pulls from a server, authenticated by certificates Ignoring certificate signing when a new node will not check in
OpenTofu Infrastructure as code through provider APIs Provisions resources and tracks them in a state file Using it to manage packages inside an OS

Kubernetes vs. Docker Swarm vs. Compose

ConceptMeaningKey differenceCommon trap
Kubernetes Cluster orchestrator using Pods, Deployments and Services Rich scheduling, self-healing and scaling across many nodes Assuming Secrets are encrypted by default
Docker Swarm Docker's built-in clustering of nodes running services as tasks Simpler orchestration integrated with Docker Confusing a Swarm service with a single container
Docker/Podman Compose Defines a multi-container application in a compose file Single host; up, down and logs for the stack Expecting multi-node failover from Compose

Bash tests: -eq vs. = vs. [[ =~ ]] vs. -z/-n

ConceptMeaningKey differenceCommon trap
-eq, -gt, -ge and similar Integer comparison Compares numeric value Using them on non-numeric strings, which errors
=, ==, !=, <, > String comparison Compares characters in sort order Comparing numbers of different lengths
[[ $var =~ regex ]] Regular expression match Works only in [[ ]]; quoting the regex makes it literal Using it inside single brackets
-z and -n String is empty or not empty Test length, not content Leaving the variable unquoted inside single brackets

git reset vs. git stash vs. git checkout

ConceptMeaningKey differenceCommon trap
git reset Moves the branch pointer and optionally the index and working tree --soft keeps changes staged, --mixed unstages, --hard discards Using --hard when work should be kept
git stash Shelves uncommitted changes for later Restore with git stash pop or apply Forgetting stashed work exists
git checkout Switches branches or restores files -b creates and switches to a new branch Switching branches with conflicting uncommitted changes

Exam traps

Each trap is an answer that looks right. Learn the clue that should change your mind.

  1. String comparison on numbers

    What candidates pick
    if [[ $usage > 90 ]] to alert on high disk usage.
    Why it looks right
    > reads like "greater than" in every other language.
    Why it's wrong
    Inside [[ ]] it compares strings, so 100 sorts before 90 and the alert never fires at 100%; use -gt or -ge.

    Clue to watch for Numeric thresholds with values of different digit lengths.

  2. Agent tool for an agentless requirement

    What candidates pick
    Puppet to configure servers where no new software may be installed.
    Why it looks right
    Puppet is a well-known configuration management tool.
    Why it's wrong
    Puppet's standard model needs an agent and certificate trust on each node; Ansible only needs SSH and Python.

    Clue to watch for "No agents" or "only SSH access" in the requirements.

  3. Kickstart for cloud images

    What candidates pick
    A Kickstart file to configure new cloud VMs at launch.
    Why it looks right
    Kickstart is the classic unattended deployment answer.
    Why it's wrong
    Cloud instances boot from prebuilt images without running an installer; cloud-init applies user data at first boot.

    Clue to watch for Instances launched from images, user data, or a cloud provider.

  4. .gitignore after the fact

    What candidates pick
    Add a committed secrets file to .gitignore to stop tracking it.
    Why it looks right
    .gitignore is the tool for excluding files.
    Why it's wrong
    It only applies to untracked files; the committed file stays tracked until removed with git rm --cached, and the secret remains in history and should be rotated.

    Clue to watch for The file is already in the repository.

  5. sudo pip install

    What candidates pick
    sudo pip install to fix a missing Python module for an admin script.
    Why it looks right
    It makes the module available system-wide in one step.
    Why it's wrong
    It can overwrite distribution-managed packages and break system tools; a virtual environment isolates the dependency.

    Clue to watch for A script with third-party dependencies on a server whose own tools use Python.

  6. Trusting runnable AI output

    What candidates pick
    Deploy an AI-generated firewall or IaC change because it ran cleanly in a quick test.
    Why it looks right
    It saves time and appears correct.
    Why it's wrong
    Generated code can be insecure or subtly wrong; responsible use requires human review, validation and corporate approval.

    Clue to watch for Production systems, security settings or compliance requirements are involved.

Answer framework

For an automation scenario, decide the scope and the constraints before choosing between a script, a tool or a platform.

  1. Identify the scale and target: one host, a fleet of existing servers, new cloud resources, first-boot instances or containers.
  2. List the constraints given, such as no agents, declarative state, version history, secrets handling or multi-node failover.
  3. Match the tool: Bash or Python for local tasks, Ansible or Puppet for configuration, OpenTofu for resources, cloud-init or Kickstart for deployment, Kubernetes or Compose for containers.
  4. When reading code, check comparison operators, quoting, exit-code handling, variable scope and indentation before anything else.
  5. Prefer the reviewable, reversible path: commit to Git, avoid rewriting shared history, test generated or changed code, and follow corporate AI policy.

Practice question

A monitoring script stores the root filesystem's usage percentage as an integer in the variable usage. Which test correctly runs the alert block when usage is 90 percent or higher, including values such as 100?

Choose one answer

Want more like this? The CompTIA Linux+ practice test has questions for every domain.

Checklist

0 of 14

Tick each one you can do without notes. Your ticks stay in this browser.

Study strategy

Start with Bash scripting (4.2), because it is a scenario objective where reading code decides the answer. Write small scripts that check disk usage, loop over log files and parse arguments, and deliberately trigger the classic bugs: unquoted variables with spaces, > instead of -gt, and $? read too late. Then do Git (4.4) hands-on in a throwaway repository: branch, stash, squash-merge, rebase a local branch, tag a release and recover from a committed secrets file.

Next, cover objective 4.1 by architecture rather than syntax. Run one Ansible playbook against a lab VM, read a short OpenTofu configuration and its plan output, launch a cloud-init-configured VM if you can, and deploy a two-container Compose stack. For Kubernetes, learn what each named object does and how they connect.

The commonly underestimated areas are Python basics (virtual environments, data types, PEP 8) and responsible AI use, both short but new to many candidates. Read the objective bullets closely, since summarize questions test vocabulary.

Afterwards, practise with snippet-reading questions and timed mixed sets, and for each miss note whether the error was about tool architecture or code behaviour.

FAQ

How much is Automation, Orchestration, and Scripting worth?

It is 17% of XK0-006 with five official objectives, the smallest domain by weight. Against the 90-question maximum that is about 15 items, an editorial planning estimate.

Do I need to write full scripts on the exam?

Objective 4.2 is a "given a scenario" objective, so expect to read, complete or debug Bash snippets. Hands-on practice writing short scripts is the most reliable preparation.

How much Python is on Linux+?

Objective 4.3 is a summarize objective covering virtual environments, built-in modules, installing dependencies, core data types, modules and packages, indentation and PEP 8. It tests foundations, not advanced programming.

Is Terraform on the XK0-006 objectives?

The objectives name OpenTofu, the open-source infrastructure-as-code tool that shares Terraform's configuration approach. Learn its concepts of providers, resources and state.

Which Kubernetes objects should I know?

The objectives list ConfigMaps, Secrets, Pods, Deployments, Volumes, Services and variables. Know what each does and which one solves a given requirement, rather than full manifest syntax.

What does the AI objective actually test?

Objective 4.5 covers using AI for code, regex, IaC, documentation and review, along with verifying output, protecting data, choosing local versus public models and following corporate policy. Expect best-practice questions rather than tool-specific ones.

How does this domain relate to the rest of the exam?

It automates the tasks from System Management and Services and User Management, and its outputs, such as scripts, playbooks and container deployments, are common sources of the failures you diagnose in Troubleshooting.

Other Networking certifications

Where the same subject shows up in other exams. Cards marked "Same subject" open the matching domain.

Test your Domain 4 knowledge

You have covered infrastructure as code, unattended deployment, CI/CD and orchestration, Bash scripting, Python basics, Git and responsible AI use. Test whether you can read a snippet and pick the right tool under time pressure.

Keep going