Courseiva

XK0-006 · domain

Automation, Orchestration, and Scripting

Practise CompTIA Linux+ (XK0-006) Automation, Orchestration, and Scripting practice questions — original exam-style scenarios with answer choices, explanations, and analysis of common mistakes.

103 questions24 easy52 medium27 hard

Focused practice

Practice Automation, Orchestration, and Scripting questions

Scored sessions drawing only from this domain — pick a length below.

Start 20-question practice test →

What this domain covers

What to know about Automation, Orchestration, and Scripting

Automation, Orchestration, and Scripting questions test whether you can apply the concept in context, not just recognise a definition.

How the topic appears in realistic exam-style scenarios.

Which detail in the question changes the correct answer.

How to eliminate plausible but wrong options.

How to connect the question back to the wider exam objective.

Watch out for

Common Automation, Orchestration, and Scripting exam traps

  • Answering from memory before reading the full scenario.
  • Missing a constraint such as cost, availability, security, scope or command context.
  • Choosing a broad answer when the question asks for the most specific fix.
  • Ignoring why the wrong options are tempting.

Question index

All Automation, Orchestration, and Scripting questions (103)

Click any question to see the full explanation, or start a practice session above.

1

An administrator is managing a Kubernetes cluster. A pod is running but not responding as expected. The administrator wants to view the standard output logs from the pod's main container. Which kubectl command should be used?

Hard
2

A Kubernetes administrator needs to expose a deployment externally using a Service. Which THREE of the following Service types can be used? (Select THREE).

Medium
3

A system administrator is writing a Bash script that must check if a file exists and is readable. Which two test expressions can be used to achieve this? (Choose two.)

Medium
4

An Ansible playbook includes a handler that restarts a service when a configuration file is changed. Which directive in a task triggers the handler?

Medium
5

A container is running a web server on port 8080 internally, and the administrator wants to access it on the host on port 80. Which Docker run option accomplishes this?

Medium
6

A system administrator wants to create a bind mount in Docker to share a host directory `/data` with a container at `/mnt/data`. Which of the following docker run options should be used?

Hard
7

A user wants to run a Docker container in detached mode, remove it automatically after it stops, and map host port 8080 to container port 80. Which command accomplishes this?

Easy
8

A Linux administrator wants to ensure a bash script stops execution immediately if any command fails. Which line should be added to the script?

Easy
9

Which of the following is a key difference between Docker and Podman?

Easy
10

An administrator wants to use Ansible to ensure a service is running on a remote host. Which Ansible module should be used in a playbook?

Medium
11

An administrator needs to create a Docker image from a Dockerfile located in the current directory and tag it as 'myapp:v1'. Which command should be used?

Medium
12

A system administrator is creating an Ansible playbook to deploy a web server on a group of hosts. The playbook needs to install the nginx package, start the service, and ensure it is enabled on boot. Which playbook structure is correct?

Hard
13

A Linux administrator is writing a Bash script that must accept command-line options for an input file (-i) and an output file (-o). Which of the following are valid methods to parse these options? (Choose TWO.)

Medium
14

A bash script uses a loop to iterate over files in a directory. Which TWO of the following loop constructs will correctly iterate over each .txt file in the current directory? (Select TWO).

Medium
15

A Bash script contains the following line: set -e. What is the effect of this command?

Medium
16

In bash, what is the difference between single quotes and double quotes?

Easy
17

An administrator is troubleshooting a Pod in a Kubernetes cluster that is not starting. Which TWO kubectl commands are most useful for diagnosing the issue? (Choose TWO.)

Medium
18

A Linux administrator needs to write a Bash script that runs a series of commands and stops immediately if any command fails. Which directive should be included at the beginning of the script?

Easy
19

A Kubernetes administrator needs to expose a deployment named 'web-app' running on port 80 internally within the cluster. Which kubectl command creates a service of type ClusterIP that maps port 80 to the target port 8080 on the pods?

Hard
20

A systems administrator is writing a bash script that must accept command-line options: -f for a configuration file, -v for verbose mode, and -d for a directory. Which TWO of the following are correct ways to parse these options using getopts? (Select TWO).

Medium
21

A Docker container is running in the background. Which command allows the administrator to execute an interactive bash shell inside the running container named 'webapp'?

Easy
22

A Linux administrator is writing a bash script to process a list of usernames stored in an array. The script must iterate over each username and print a welcome message. Which TWO of the following loops will correctly iterate over the array 'users' and print 'Welcome, <username>'? (Choose TWO.)

Medium
23

A Linux administrator writes a bash script that needs to exit immediately if any command fails. Which of the following should be included at the beginning of the script?

Easy
24

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?

Medium
25

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.)

Hard
26

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?

Easy
27

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?

Hard
28

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?

Medium
29

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?

Medium
30

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

Medium
31

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?

Medium
32

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

Easy
33

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

Hard
34

In a Bash script, what is the purpose of the shebang '#!/bin/bash'?

Easy
35

A Linux administrator needs to run a Docker container in detached mode with port mapping from host port 8080 to container port 80, and mount a host directory /data to /app/data inside the container. Which command achieves this?

Medium
36

In a Bash script, what is the correct way to check if a file named '/etc/passwd' exists and is a regular file?

Easy
37

A developer wants to run a containerized application using Podman in a rootless environment. Which of the following is a key difference between Podman and Docker that the developer should be aware of?

Medium
38

A containerized application uses a volume to persist data. The administrator needs to create a new volume named 'data-vol' and mount it to /app/data in the container. Which of the following commands accomplish this? (Select all that apply.)

Hard
39

A DevOps engineer is writing a Dockerfile. The application requires environment variables to be set at runtime from a file. Which Dockerfile instruction should be used to achieve this?

Medium
40

An administrator is writing a bash script that loops through all .log files in /var/log and prints the file name if the file is larger than 100 kilobytes. Which loop correctly implements this?

Hard
41

A system administrator is writing a bash script that must check if a file exists and is readable before processing. Which TWO test expressions can be used in an if statement? (Select TWO.)

Medium
42

In a Bash script, the administrator wants to capture the output of a command into a variable. Which syntax should be used?

Hard
43

In a Bash script, what is the difference between single quotes and double quotes?

Easy
44

A DevOps engineer is creating a Dockerfile for a Node.js application. Which THREE of the following instructions are valid and commonly used in a Dockerfile? (Choose THREE.)

Hard
45

A Docker container needs to persistently store data that should survive container removal and be accessible by other containers. Which storage method should be used?

Medium
46

An administrator writes a bash script that uses a function to check if a file exists and is readable. The function returns 0 if the file meets the conditions, and 1 otherwise. Which of the following correctly implements this function?

Medium
47

A team uses Ansible for configuration management. They want to ensure a service is running on all managed nodes. Which Ansible module should be used in the playbook?

Medium
48

A Linux administrator is writing a bash script that needs to iterate over all files ending with .log in /var/log and output the number of lines in each file. Which loop construct should be used?

Medium
49

A DevOps engineer is building a Docker image for a web application. They want to ensure the image is as small as possible and that sensitive data is not left in layers. Which two practices help achieve these goals? (Choose TWO.)

Hard
50

In a bash script, a developer needs to parse command-line options such as -f filename and -v (verbose). Which built-in command is best suited for this task?

Medium
51

An administrator is investigating a Bash script that is failing unexpectedly. They want to see each command as it is executed to debug the script. Which command should be added to the script?

Hard
52

In a Bash script, the following array is defined: fruits=('apple' 'banana' 'cherry'). Which syntax correctly iterates over all elements of the array?

Medium
53

A Linux administrator is writing a bash script that must exit immediately if any command fails. Which of the following should be included at the beginning of the script?

Easy
54

A Bash script contains the following function: ```bash myfunc() { local result="$(( $1 + $2 ))" echo "$result" } ``` If the script calls `myfunc 5 10`, what is the output?

Medium
55

In a bash script, a function is defined to calculate a value. Which TWO of the following are valid ways to return a value from the function to the caller? (Select TWO).

Medium
56

In an Ansible playbook, which THREE of the following are valid modules for managing files and packages? (Select THREE).

Medium
57

A Linux administrator writes a Bash script and includes the line `#!/bin/bash` at the top. What is the purpose of this line?

Easy
58

A system administrator is writing a Bash script that needs to iterate over a list of IP addresses stored in a file, one per line. Which loop construct should be used?

Medium
59

A developer is writing a Dockerfile. The application requires a configuration file that should be copied from the build context and the container should expose port 8080. Which combination of Dockerfile instructions is correct?

Medium
60

A DevOps engineer is writing a Bash script that iterates over all items in an array. The array is declared as 'fruits=("apple" "banana" "cherry")'. Which loop correctly iterates over each element?

Hard
61

In a Bash script, which THREE of the following are valid ways to define a function? (Select THREE.)

Medium
62

Which of the following Bash variable expansions will result in the string "Hello World"?

Easy
63

In a Bash script, a variable is assigned the output of a command using: result=$(ls -l). What is the purpose of the $() syntax?

Medium
64

A system administrator needs to update a configuration file on multiple servers using Ansible. The playbook must ensure the line 'MaxAuthTries 3' is present in /etc/ssh/sshd_config. Which Ansible module is most appropriate?

Medium
65

In a bash script, a variable is set as follows: myvar='Hello World'. Which of the following correctly prints the first 5 characters of the variable?

Hard
66

An administrator is debugging a Docker container that exits immediately after starting. Which THREE commands can help diagnose the issue? (Select THREE).

Hard
67

A Linux administrator is troubleshooting a Bash script that unexpectedly terminates when a command fails. The script uses `#!/bin/bash`. Which of the following commands, if placed at the beginning of the script, would cause it to exit on any command failure?

Hard
68

A DevOps engineer wants to run a Docker container with a bind mount to make a host directory /data available at /mnt/data inside the container. Which command is correct?

Medium
69

A DevOps engineer is writing a Bash script to automate deployment of a containerized application. The script must: (1) exit immediately if any command fails, (2) build a Docker image with tag 'myapp:latest' from the current directory, (3) run a container from that image in detached mode with port mapping 8080:80, (4) set environment variable ENV=production inside the container, and (5) bind mount a host directory /data to /app/data inside the container. Which TWO of the following snippets should be included in the script to meet these requirements? (Choose TWO.)

Hard
70

A developer is writing a Bash script that needs to test whether a file exists and is readable. Which of the following conditionals correctly performs this check?

Medium
71

A Linux administrator is writing a bash script that accepts command-line options: -a for all, -f for file, and -o for output. Which of the following correctly uses getopts to parse these options?

Medium
72

A container is running and a technician needs to execute an interactive shell inside it. The container was started with 'docker run -d --name myapp myimage'. Which command will achieve this?

Medium
73

A Linux administrator wants to create a Docker image from a Dockerfile. Which TWO of the following commands are needed? (Select TWO).

Easy
74

A system administrator needs to create a Dockerfile for a Python application. The application should be installed in the container, and when the container starts, it should run the command 'python app.py'. Which Dockerfile instruction should be used to specify the default command?

Medium
75

A DevOps team is designing a containerized application using Docker Compose. They need to ensure that the database container is started before the application container. Which of the following Docker Compose directives can be used to control startup order? (Choose TWO.)

Hard
76

A Linux administrator wants to run a container that stops automatically after the main process exits. Which Docker run flag should be used?

Easy
77

A Linux administrator is writing a Bash script that must handle errors gracefully. Which TWO of the following techniques ensure the script exits on error and provides debugging information? (Select TWO.)

Medium
78

A DevOps engineer needs to run a Docker container in the background with port mapping from host port 8080 to container port 80, and name the container 'webapp'. Which command accomplishes this?

Easy
79

A cloud engineer is using Ansible to manage configuration across multiple servers. The engineer needs to store variable data that is specific to each host and sensitive database passwords. Which two Ansible features should be used for these purposes? (Choose two.)

Medium
80

A Bash script contains the following code: if [[ $# -eq 0 ]]; then echo 'No arguments'; fi. What does this code check?

Easy
81

An Ansible playbook is being written to install the Nginx web server on a group of Ubuntu servers. Which module should be used in the playbook to install the package?

Medium
82

In a bash script, an administrator wants to check if a file exists and is readable. Which of the following test expressions accomplishes this?

Medium
83

A developer wants to view the logs from a running Docker container named 'myapp'. Which docker command should be used?

Easy
84

A Kubernetes administrator needs to expose a deployment named 'webapp' as a service accessible externally on port 80. Which kubectl command should be used?

Medium
85

An administrator needs to deploy a set of microservices using Docker Compose. The services require configuration values that vary between development and production environments. Which approach allows the administrator to override values without modifying the docker-compose.yml file?

Hard
86

A containerized application uses a bind mount to persist logs. When the container is removed and recreated, the logs are missing. What is the most likely cause?

Hard
87

A developer is writing a Bash script that needs to parse command-line options with arguments, such as -f filename and -v. Which built-in command should be used to handle these options?

Medium
88

Which Dockerfile instruction sets the command to run when the container starts, but allows the user to override it when using docker run?

Easy
89

An administrator needs to create a Docker network of type 'bridge' so that containers can communicate with each other by name. Which command creates a user-defined bridge network named 'my-net'?

Hard
90

A developer creates a Dockerfile for a web application. Which instruction should be used to define the command that runs when the container starts, allowing the container to accept arguments from the docker run command?

Medium
91

A Docker container needs persistent storage that survives container restarts. Which of the following is the recommended method to achieve this?

Easy
92

A DevOps engineer is writing a Dockerfile for a Python web application. The base image is python:3.9-slim. The application code is in the current directory, and the container should expose port 8080. Which Dockerfile instructions correctly build the image and run the application using python app.py?

Medium
93

A Kubernetes administrator is creating a deployment YAML manifest. Which THREE fields are required in a Deployment spec? (Select THREE.)

Hard
94

An administrator wants to run a script on multiple remote servers using Ansible. The script requires a variable that differs per host. Where should the administrator define this variable to follow best practices?

Hard
95

Which Kubernetes resource is used to store non-sensitive configuration data as key-value pairs that can be consumed by pods?

Easy
96

An Ansible playbook is being written to manage web servers. Which TWO modules can be used to ensure a package is installed? (Select TWO.)

Medium
97

A user wants to execute a command inside a running Docker container named 'db'. Which command should be used?

Easy
98

A Kubernetes YAML manifest defines a Deployment with 3 replicas. The administrator runs `kubectl get pods` and sees 3 running pods. They then run `kubectl scale deployment mydeployment --replicas=5`. What command would confirm the new number of replicas?

Medium
99

A system administrator is writing an Ansible playbook to manage a web server. Which three of the following are valid Ansible modules for system administration? (Choose THREE.)

Medium
100

A Bash script uses getopts to parse command-line options. The options are -a (requires an argument) and -b (flag). Which code correctly implements this and stores the argument for -a in $optarg?

Hard
101

A bash script needs to test whether a string variable $NAME is non-empty and equals 'admin'. Which of the following conditionals is correct?

Medium
102

An administrator is writing a Dockerfile. They need to set a default command that can be overridden when running the container. Which instruction should be used?

Hard
103

A DevOps team uses Podman to run containers rootlessly. Which TWO of the following characteristics apply to rootless Podman compared to Docker? (Select TWO).

Hard

Frequently asked questions

What does the Automation, Orchestration, and Scripting domain cover on the XK0-006 exam?
Automation, Orchestration, and Scripting questions test whether you can apply the concept in context, not just recognise a definition.
How many questions are in this domain?
This page lists all 103 Automation, Orchestration, and Scripting questions in the XK0-006 question bank. The actual exam draws from this domain proportionally to its weighting in the official exam blueprint.
What is the best way to practise this domain?
Start with a short focused session (10 questions) to identify gaps, then work through explanations. Repeat with a longer session once the weak areas feel solid.
Can I practise only Automation, Orchestration, and Scripting questions?
Yes — the session launcher on this page filters questions to this domain only. Choose any session length for inline explanations and scoring.
linux-plus LINUX-PLUS lxp scripting containers Practice Questions