XK0-005 · topic practice

Scripting, Containers and Automation practice questions

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

Courseiva uses original exam-style practice questions designed for learning and revision. The goal is to understand the concepts, recognise exam patterns, and improve through explanations — not memorise copied exam dumps.

Reviewed byJohnson Ajibi· MSc IT Security
20 questionsDomain: Scripting, Containers and Automation

What the exam tests

What to know about Scripting, Containers and Automation

Scripting, Containers and Automation 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 Scripting, Containers and Automation 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.

Practice set

Scripting, Containers and Automation questions

20 questions · select your answer, then reveal the explanation

A DevOps engineer needs to ensure that a containerized web application always restarts automatically if the container exits unexpectedly. Which Docker run option should be used?

A system administrator wants to create a new user and set a password in a single command as part of a provisioning script. Which command accomplishes this?

A Linux server that hosts a critical database application has been experiencing occasional kernel panics. The administrator wants to ensure the system automatically reboots after a panic and logs the crash dump. Which sysctl parameter should be set?

A developer wants to run a container with a specific command that overrides the default entrypoint. Which Docker command should be used?

A senior administrator is troubleshooting a shell script that fails to execute properly. The script starts with #!/bin/bash and has execute permissions. Which of the following could cause the script to fail to run when invoked as ./script.sh?

Question 6mediummultiple choice
Read the full Ansible explanation →

A cloud engineer needs to automate the deployment of a new virtual machine with a specific configuration using Ansible. Which file format is typically used for Ansible playbooks?

A developer is writing a Bash script that must be portable across different Linux distributions. The script needs to check if a package is installed. Which command should be used to achieve this portability?

A junior administrator needs to view the logs of a running container named 'webapp'. Which command should be used?

A Linux administrator is writing a script that must wait for a background process to finish before continuing. The process ID is stored in a variable. Which command should be used to wait for this process?

A systems administrator wants to build a custom Docker image from a Dockerfile located in the current directory. Which command should be used?

Which TWO of the following are valid methods to pass environment variables to a Docker container at runtime?

A Linux administrator needs to implement a cron job that runs a script every day at 2:30 PM. Which TWO cron schedule expressions are equivalent?

Which THREE of the following are valid systemd unit types?

A developer is writing a shell script that needs to handle errors. Which THREE of the following are best practices for robust script error handling?

Based on the exhibit, what is the most likely cause of the repeated connection refused errors?

Exhibit

Refer to the exhibit.

```
$ cat /var/log/containers/web.log | grep "ERROR" | head -5
[2024-03-21 10:15:23] ERROR: Connection refused to database at 10.0.0.1:3306
[2024-03-21 10:15:24] ERROR: Connection refused to database at 10.0.0.1:3306
[2024-03-21 10:15:25] ERROR: Connection refused to database at 10.0.0.1:3306
[2024-03-21 10:15:26] ERROR: Connection refused to database at 10.0.0.1:3306
[2024-03-21 10:15:27] ERROR: Connection refused to database at 10.0.0.1:3306
```

After building and running the container as shown in the exhibit, the administrator tries to access http://localhost:8080 but receives a connection refused error. What is the most likely cause?

Exhibit

Refer to the exhibit.

```
$ cat Dockerfile
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y nginx
COPY index.html /var/www/html/
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
$ docker build -t webapp .
$ docker run -d -p 8080:80 webapp
```

Based on the exhibit, how often does the healthcheck.sh script run?

Exhibit

Refer to the exhibit.

```
$ crontab -l
*/5 * * * * /usr/local/bin/healthcheck.sh
```

A company runs a critical web application on a single Linux server. The application consists of a Node.js backend and a PostgreSQL database. The server is running out of disk space frequently due to application logs. The administrator wants to implement a log rotation solution that is automated, minimizes data loss, and compresses old logs. The administrator has root access and wants to use built-in tools. Currently, logs are written to /var/log/app/access.log and /var/log/app/error.log. The application never closes its log files. Which of the following is the best course of action?

A development team uses Git for version control and wants to automate the testing of every commit pushed to the repository. They have a Jenkins server running on a Linux machine. The team wants to automatically trigger a Jenkins pipeline job whenever a push is made to the main branch of their Git repository. The Jenkins server is behind a firewall and cannot be accessed from the internet. The Git repository is hosted on a private GitHub repository. Which of the following is the best approach to trigger the Jenkins job automatically?

An administrator needs to deploy a containerized web application on a Linux server. The application requires port 8080 to be mapped to host port 80. Which command will run the container in detached mode with this port mapping?

Free account

Track your progress over time

Create a free account to save your results and see which topics improve across sessions.

Focused Scripting, Containers and Automation sessions

Start a Scripting, Containers and Automation only practice session

Every question in these sessions is drawn from the Scripting, Containers and Automation domain — nothing else.

Related practice questions

Related XK0-005 topic practice pages

Move into related areas when this topic feels solid.

Frequently asked questions

What does the XK0-005 exam test about Scripting, Containers and Automation?
Scripting, Containers and Automation questions test whether you can apply the concept in context, not just recognise a definition.
How should I use these practice questions?
Select your answer before revealing the explanation. Then read why each option is right or wrong — this active recall approach builds retention far faster than re-reading notes.
Can I practise just Scripting, Containers and Automation questions in a focused session?
Yes — the session launcher on this page draws every question from the Scripting, Containers and Automation domain. Use a 10-question session first to gauge your baseline, then move to 20 or 30 once the weak spots are clear.
Where can I practise other XK0-005 topics?
Use the topic links above to move to related areas, or go back to the XK0-005 question bank to see all topics.
Are these real exam questions or dumps?
These are original practice questions written to test the same concepts the XK0-005 exam covers. They are not copied from any real exam or dump site.