Courseiva
Knowledge + Practice
CertificationsVendorsCareer RoadmapsLabs & ToolsStudy GuidesGlossaryPractice Questions
C
Courseiva

Free IT certification practice questions with explained answers for CCNA, CompTIA, AWS, Azure, Google Cloud, and more.

Certification Practice Questions

CCNA practice questionsSecurity+ SY0-701 practice questionsAWS SAA-C03 practice questionsAZ-104 practice questionsAZ-900 practice questionsCLF-C02 practice questionsA+ Core 1 practice questionsGoogle Cloud ACE practice questionsCySA+ CS0-003 practice questionsNetwork+ N10-009 practice questions
View all certifications →

Product

CertificationsCertification PathsExam TopicsPractice TestsExam Dumps vs Practice TestsStudy HubComparisons

Company

AboutContactEditorial PolicyQuestion Writing PolicyTrust Center

Legal

Privacy PolicyTerms of Service

Courseiva is a free IT certification practice platform offering original exam-style practice questions, detailed explanations, topic-based practice, mock exams, readiness tracking, and study analytics for Cisco, CompTIA, Microsoft, AWS, and other technology certifications.

© 2026 Courseiva. Courseiva is operated by JTNetSolutions Ltd. All rights reserved.

Courseiva is an independent certification practice platform and is not affiliated with, endorsed by, or sponsored by Cisco, Microsoft, AWS, CompTIA, Google, ISC2, ISACA, or any other certification vendor. Vendor names and certification marks are used only to identify the exams learners are preparing for.

← Scripting, Containers and Automation practice sets

XK0-005 Scripting, Containers and Automation • Complete Question Bank

XK0-005 Scripting, Containers and Automation — All Questions With Answers

Complete XK0-005 Scripting, Containers and Automation question bank — all 0 questions with answers and detailed explanations.

151
Questions
Free
No signup
Certifications/XK0-005/Practice Test/Scripting, Containers and Automation/All Questions
Question 1mediummultiple choice
Read the full Scripting, Containers and Automation 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?

Question 2easymultiple choice
Read the full Scripting, Containers and Automation explanation →

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?

Question 3hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

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?

Question 4easymultiple choice
Read the full Scripting, Containers and Automation explanation →

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

Question 5hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

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?

Question 7mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

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?

Question 8easymultiple choice
Read the full Scripting, Containers and Automation explanation →

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

Question 9hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

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?

Question 10mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

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

Question 11mediummulti select
Read the full Scripting, Containers and Automation explanation →

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

Question 12hardmulti select
Read the full Scripting, Containers and Automation explanation →

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?

Question 13easymulti select
Read the full Scripting, Containers and Automation explanation →

Which THREE of the following are valid systemd unit types?

Question 14hardmulti select
Read the full Scripting, Containers and Automation explanation →

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?

Question 15mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

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
```
Question 16hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

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
```
Question 17easymultiple choice
Read the full Scripting, Containers and Automation explanation →

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
```
Question 18hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

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?

Question 19mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

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?

Question 20mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

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?

Question 21hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A Linux system experiences high CPU usage from a process that appears to be a fork bomb. The administrator wants to prevent such attacks in the future by limiting the number of processes a user can create. Which configuration file should be modified, and what parameter should be set?

Question 22easymultiple choice
Read the full Ansible explanation →

A DevOps engineer needs to automate the deployment of a microservice using Ansible. The playbook should install the latest version of nginx on all web servers. Which Ansible module should be used in the playbook?

Question 23mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A container is running a database service that requires persistent storage. The administrator wants to ensure that data persists even if the container is removed. Which volume mount type should be used in the Docker run command?

Question 24hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A system administrator notices that a cron job runs every 5 minutes but should run only on weekdays. The current crontab entry is: */5 * * * * /usr/local/bin/script.sh. Which change to the time fields will restrict execution to Monday through Friday?

Question 25mediummulti select
Read the full Scripting, Containers and Automation explanation →

Which TWO statements about container security are correct when using Docker? (Choose two.)

Question 26hardmulti select
Read the full Scripting, Containers and Automation explanation →

Which THREE conditions must be met for a Linux container to run with user namespaces enabled? (Choose three.)

Question 27mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

An administrator runs the commands shown in the exhibit. The container is accessible via curl using the container IP. However, the administrator cannot access the web server using the host's IP address on port 80. What is the most likely cause?

Network Topology
$ docker inspect web1format='{{.NetworkSettings.IPAddress}}'Refer to the exhibit.$ docker ps172.17.0.2<!DOCTYPE html>listen 80 default_serverlisten [::]:80 default_server
Question 28hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

An administrator configures Docker as shown in the exhibit. After starting a container, the warning about the 'user' directive appears. What is the most likely cause?

Network Topology
$ docker infoformat '{{.CgroupDriver}}'$ docker run -dname app1 nginxRefer to the exhibit.$ cat /etc/docker/daemon.json"exec-opts": ["native.cgroupdriver=systemd"],"log-driver": "json-file","log-opts": {"max-size": "10m","max-file": "3"},"storage-driver": "overlay2"cgroupfs...
Question 29mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A company is deploying a new web application using Docker containers. The application requires configuration values that vary between environments (development, staging, production). Which approach ensures the configuration is securely managed and applied without modifying the container image?

Question 30hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A Linux administrator is writing a Bash script to automate the backup of a database. The script must run a pre-backup command, check its exit status, and if successful, proceed with the backup; otherwise, log an error and exit. Which code snippet correctly implements this logic?

Question 31easymultiple choice
Read the full Scripting, Containers and Automation explanation →

A DevOps engineer needs to run a container that executes a batch job and then exits. The container image is stored in a private registry. Which Docker command should be used to run the container and automatically remove it after it exits?

Question 32mediummulti select
Read the full Ansible explanation →

Which TWO statements are true regarding the use of Ansible for automation? (Choose TWO.)

Question 33mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A pod in the Kubernetes cluster is in CrashLoopBackOff. Based on the exhibit, what is the most likely cause?

Exhibit

Refer to the exhibit.

# kubectl get pods -l app=web
NAME          READY   STATUS    RESTARTS   AGE
web-0         1/1     Running   0          10m
web-1         1/1     Running   0          10m
web-2         0/1     CrashLoopBackOff   3          5m

# kubectl describe pod web-2
...
Events:
  Type     Reason     Age   From               Message
  ----     ------     ----  ----               -------
  Normal   Pulled     5m    kubelet            Container image "web-app:1.0" already present on machine
  Normal   Created    5m    kubelet            Created container web
  Normal   Started    5m    kubelet            Started container web
  Warning  BackOff    2m    kubelet            Back-off restarting failed container
  Warning  CrashLoopBackOff  1m    kubelet    CrashLoopBackOff
Question 34hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A Linux administrator is responsible for a critical application that runs as a systemd service on a server. The application occasionally hangs, and the administrator wants to automate the restart if the service becomes unresponsive. The administrator writes a Bash script that checks if the service is active and responsive by pinging a local health endpoint. If the health check fails three consecutive times, the script restarts the service. The script is intended to run every minute via a cron job. However, after implementing the cron job, the service is restarted even when it is functioning correctly, causing unnecessary downtime. The administrator reviews the script and finds the following logic:

#!/bin/bash SERVICE="myapp" COUNT_FILE="/tmp/${SERVICE}_failcount"

if curl -f http://localhost:8080/health; then

echo 0 > "$COUNT_FILE" else FAILS=$(cat "$COUNT_FILE" 2>/dev/null || echo 0) FAILS=$((FAILS + 1)) echo "$FAILS" > "$COUNT_FILE"

if [ "$FAILS" -ge 3 ]; then

systemctl restart "$SERVICE" echo 0 > "$COUNT_FILE" fi fi

What is the most likely cause of the false restarts?

Question 35easymulti select
Read the full Scripting, Containers and Automation explanation →

A Linux administrator is creating a shell script to back up configuration files to a remote server. The script must ensure that if any command fails (e.g., rsync or tar), the script exits immediately and does not continue. Which TWO of the following should be included in the script to achieve this behavior? (Choose two.)

Question 36mediummultiple choice
Read the full DNS explanation →

A DevOps engineer is responsible for deploying a containerized web application on a Linux server running Docker. The application consists of three services: a frontend (Nginx), a backend (Node.js), and a database (PostgreSQL). The engineer uses Docker Compose to manage the stack. The deployment works correctly on a test environment, but when deployed to production, the frontend service fails to connect to the backend. Both services are on the same custom bridge network. The engineer checks the logs of the frontend container and sees 'getaddrinfo EAI_AGAIN backend-service'. The backend service is running and healthy. The engineer suspects a DNS resolution issue within the Docker network. Which of the following is the most likely cause and correct solution?

Question 37mediumdrag order
Read the full Scripting, Containers and Automation explanation →

Drag and drop the steps to mount a new filesystem in the correct order.

Drag steps to the numbered slots on the right, or tap a step then tap a slot.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4
5Step 5
Question 38mediumdrag order
Read the full Scripting, Containers and Automation explanation →

Drag and drop the steps to create and apply a systemd service unit in the correct order.

Drag steps to the numbered slots on the right, or tap a step then tap a slot.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4
5Step 5
Question 39mediummatching
Read the full Scripting, Containers and Automation explanation →

Match each Linux command to its primary function.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

List block devices

List open files

Manage partition tables

Inform OS of partition changes

Display block device attributes

Question 40mediummatching
Read the full Scripting, Containers and Automation explanation →

Match each Linux process signal to its typical action.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

Hangup, often reload config

Interrupt from keyboard (Ctrl+C)

Force kill (cannot be caught)

Terminate gracefully

Stop/pause process (cannot be caught)

Question 41easymultiple choice
Read the full Scripting, Containers and Automation explanation →

A junior administrator is asked to automate the backup of a configuration file every night at 11 PM. The script /usr/local/bin/backup.sh already exists. Which command should the administrator run to schedule this task?

Question 42mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A system administrator wants to ensure that a container can access host devices such as USB drives. Which Docker run option should be used?

Question 43hardmultiple choice
Study the full Python automation breakdown →

An administrator is tasked with creating a systemd service that runs a Python script after the network is available. The script must restart automatically if it fails. Which systemd service unit directive should be used to ensure restart on failure?

Question 44easymultiple choice
Read the full Scripting, Containers and Automation explanation →

Which command will run a container in detached mode with the name 'web' and map host port 8080 to container port 80, using the nginx image?

Question 45mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

An administrator needs to create a shell script that will be executed by a non-login shell. The script requires access to environment variables set in the user's profile. Which file should the script source to ensure these variables are available?

Question 46hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A container needs to communicate with a database on the host machine using the default bridge network. The container cannot resolve the host by hostname. Which approach should be used?

Question 47easymultiple choice
Read the full Scripting, Containers and Automation explanation →

What does the `set -x` command do when placed at the top of a bash script?

Question 48mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A DevOps engineer is writing a unit file for a systemd service that should start after the network-online.target. Which directive should be added to the [Unit] section?

Question 49hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A containerized application writes logs to /var/log/app.log. The administrator wants to ensure logs persist even if the container is removed. Which approach should be used?

Question 50mediummulti select
Read the full Scripting, Containers and Automation explanation →

Which two of the following are valid methods to pass environment variables to a Docker container at runtime? (Select TWO.)

Question 51hardmulti select
Read the full Scripting, Containers and Automation explanation →

A system administrator is troubleshooting a bash script that fails when run from cron but works when run from the terminal. Which two factors could explain this behavior? (Select TWO.)

Question 52easymulti select
Read the full Scripting, Containers and Automation explanation →

A Linux administrator is writing a systemd service unit file. Which three of the following directives are valid in the [Service] section? (Select THREE.)

Question 53mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

Refer to the exhibit. A Docker container using a bind mount fails to start with a permission error. What is the most likely cause?

Exhibit

Mar 10 08:15:22 host dockerd[1234]: Time=2025-03-10T08:15:22.123Z Level=error msg="failed to mount local volume: mount :/var/lib/docker/volumes/vol1/_data:/data, flags: 0x1000: permission denied"
Mar 10 08:15:22 host dockerd[1234]: Time=2025-03-10T08:15:22.124Z Level=error msg="error while mounting volume: permission denied"
Question 54hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

Refer to the exhibit. The service fails to start with the error 'Failed to start My Service: Unit not found'. What is the most likely cause?

Exhibit

[Unit]
Description=My Service
After=network.target

[Service]
ExecStart=/usr/local/bin/myservice.sh
Restart=always
User=nobody

[Install]
WantedBy=multi-user.target
Question 55easymultiple choice
Read the full Scripting, Containers and Automation explanation →

Refer to the exhibit. A system administrator notices that the cleanup script runs at 2:00 AM every day but sometimes does not execute. The log shows no output from the script. Which step should be taken to investigate?

Exhibit

$ crontab -l
0 2 * * * /usr/local/bin/cleanup.sh
Question 56easymultiple choice
Read the full Scripting, Containers and Automation explanation →

A systems administrator needs to automate the execution of a backup script every day at 2:00 AM using a systemd service. Which unit type should the administrator create?

Question 57easymultiple choice
Study the full Python automation breakdown →

A developer writes a Python script that uses the `requests` library to fetch data from an API. The script works on the developer's workstation but fails on the server with an import error. What is the most likely cause?

Question 58easymultiple choice
Read the full Ansible explanation →

An administrator wants to use Ansible to ensure that the `httpd` package is installed on all managed nodes. Which Ansible module should be used?

Question 59mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A DevOps engineer is designing a CI/CD pipeline for a microservices application. The pipeline should build a Docker image, run unit tests, and if successful, push the image to a private registry. Which tool is best suited for orchestrating this pipeline?

Question 60mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A Linux administrator is writing a Bash script that needs to parse a CSV file line by line and extract the second field. Which of the following approaches is the most efficient?

Question 61mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

An organization uses Kubernetes to deploy containerized applications. A pod fails to start with an ImagePullBackOff error. What is the most likely cause?

Question 62hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A sysadmin is tasked with creating a script that will run only on weekdays at 9:00 AM using cron. The script should not run on holidays. Which approach best achieves this requirement?

Question 63hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A system administrator is troubleshooting a Docker container that exits immediately after starting. The container is built from a minimal image that runs a short-lived command. Which change will keep the container running?

Question 64hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A security team requires that all scripts run from a specific directory must be signed with a GPG key before execution. Which Linux feature can enforce this policy?

Question 65mediummulti select
Read the full Scripting, Containers and Automation explanation →

Which TWO commands are used to view logs in a systemd-based system? (Choose two.)

Question 66easymulti select
Read the full Scripting, Containers and Automation explanation →

Which TWO characteristics apply to Docker containers compared to virtual machines? (Choose two.)

Question 67hardmulti select
Read the full Ansible explanation →

Which THREE statements about Ansible are true? (Choose three.)

Question 68easymultiple choice
Read the full Scripting, Containers and Automation explanation →

Refer to the exhibit. An administrator creates this systemd unit file for a backup script. When the administrator runs `systemctl start backup.service`, the script runs but the service shows 'inactive (dead)' immediately. What change should be made to keep the service active until the script finishes?

Exhibit

Refer to the exhibit.

```
[Unit]
Description=Daily Backup Service
Requires=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup.sh

[Install]
WantedBy=multi-user.target
```
Question 69mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

Refer to the exhibit. A developer is pushing an image to a private registry at `192.168.1.100:5000` but receives an error about using an insecure registry. Which part of the Docker daemon configuration allows this registry without TLS?

Exhibit

Refer to the exhibit.

```
$ cat /etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  },
  "storage-driver": "overlay2",
  "insecure-registries": ["192.168.1.100:5000"]
}
```
Question 70hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

Refer to the exhibit. The development team is using Git to manage their project. A release candidate needs to include only the changes from the `feature/update` branch, but NOT the 'Add new module' commit. Which Git command sequence should be used to create a new release branch that contains only the feature branch?

Network Topology
$ git logonelinegraphRefer to the exhibit.```* 3a1b2c3 Merge branch 'feature/update'|/* 1m2n3o4 Initial commit
Question 71mediummultiple choice
Read the full NAT/PAT explanation →

A systems administrator creates a bash script that processes log files. The script uses a for loop to iterate over files in /var/log and runs a command on each. Which of the following would prevent the script from failing if no files match the pattern?

Question 72hardmultiple choice
Read the full Ansible explanation →

An organization is migrating from a legacy automation tool to Ansible. Which of the following best describes the role of Ansible playbooks in configuration management?

Question 73easymultiple choice
Read the full Scripting, Containers and Automation explanation →

A Linux administrator needs to automate daily database backups and ensure the job runs even if the system is rebooted. Which approach should be used?

Question 74hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A developer writes a Dockerfile that installs multiple packages. To reduce the final image size, which of the following practices is most effective?

Question 75mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A Linux engineer is troubleshooting a cron job that does not execute as expected. The crontab entry reads: '*/5 * * * * /usr/local/bin/backup.sh'. The script runs manually when executed as root. Which of the following is the most likely cause?

Question 76easymultiple choice
Read the full Scripting, Containers and Automation explanation →

A system administrator wants to deploy a containerized application on a Linux server with minimal overhead and without a daemon. Which container runtime should be used?

Question 77hardmultiple choice
Read the full Ansible explanation →

A DevOps team uses Git for version control of Ansible playbooks. They notice that a recent commit introduced errors in the playbook. Which Git command sequence should they use to temporarily revert to a previous commit while preserving the faulty commit in history?

Question 78mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A junior administrator is writing a bash script that should exit immediately if any command in a pipeline fails. Which command should be added at the beginning of the script?

Question 79easymultiple choice
Read the full Scripting, Containers and Automation explanation →

An administrator needs to run a container using a specific user ID to match host file permissions. Which Docker option should be used when running the container?

Question 80hardmulti select
Read the full Scripting, Containers and Automation explanation →

Which THREE of the following are valid ways to define environment variables in a Docker container? (Choose three.)

Question 81mediummulti select
Read the full Scripting, Containers and Automation explanation →

A Linux engineer needs to ensure a bash script runs with strict error handling. Which TWO of the following should be included? (Choose two.)

Question 82mediummulti select
Read the full Scripting, Containers and Automation explanation →

Which TWO of the following are characteristics of containers compared to virtual machines? (Choose two.)

Question 83easymultiple choice
Read the full Scripting, Containers and Automation explanation →

A junior administrator writes a bash script to check disk usage and send an email alert. The script runs manually but does not execute from cron. Which of the following is the most likely cause?

Question 84mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A script uses 'set -e' and then calls a function that returns a non-zero exit status. The script exits unexpectedly. Which of the following should be added to the function to prevent the script from exiting?

Question 85hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A DevOps engineer is creating a Podman container that needs to communicate with a host service listening on a Unix socket at /run/host-service.sock. Which of the following mount options will make the socket available inside the container?

Question 86mediummulti select
Read the full Scripting, Containers and Automation explanation →

An administrator wants to ensure that a web service starts after the database service has fully initialized. Which TWO methods can be used to achieve this ordering dependency in systemd?

Question 87easymultiple choice
Read the full Ansible explanation →

A team uses Ansible for configuration management. A playbook fails with the error 'ERROR! Syntax Error while loading YAML script'. Which of the following is the most likely cause?

Question 88hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A storage administrator needs to automate the expansion of an LVM volume group when free space drops below 10%. The script must add a new physical volume from a spare disk. Which of the following commands should be used in the script to add the new disk to the volume group?

Question 89mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A script receives a JSON object where keys are user IDs. Which command extracts the 'status' of user id '123'?

Question 90hardmulti select
Read the full Scripting, Containers and Automation explanation →

A security-conscious administrator runs containers with Podman. Which THREE methods ensure that a container runs with the least privilege required?

Question 91mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A cron job runs a script that uses a command only available in a custom directory. The script fails from cron but works in the user's shell. Which of the following is the most common cause?

Question 92easymultiple choice
Read the full Scripting, Containers and Automation explanation →

A bash script uses a for loop to iterate over files in a directory. Which of the following correctly assigns each filename to the variable FILE?

Question 93hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A systemd timer unit is configured to run a service every hour but the service never executes. The timer shows as active and enabled. Which of the following is the most likely cause?

Question 94easymulti select
Read the full Scripting, Containers and Automation explanation →

A container produces a large amount of log output to stdout. Which TWO methods effectively manage log size in a production environment?

Question 95mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A container named web2 exited with status 0. Which of the following is the most likely reason?

Exhibit

Refer to the exhibit.

Exhibit:
$ podman ps -a
CONTAINER ID  IMAGE                           COMMAND               CREATED        STATUS                    PORTS       NAMES
a1b2c3d4e5f6  docker.io/library/nginx:latest  nginx -g 'daemon of…  2 hours ago    Up 2 hours (unhealthy)    0.0.0.0:80->80/tcp  web1
f6e5d4c3b2a1  docker.io/library/nginx:latest  nginx -g 'daemon of…  3 hours ago    Exited (0) 3 hours ago               web2
Question 96easymultiple choice
Read the full Scripting, Containers and Automation explanation →

The backup script above always outputs 'Backup failed' even when the tar command succeeds. Which of the following is the cause?

Exhibit

Refer to the exhibit.

Exhibit:
#!/bin/bash
# Script to backup /var/www
tar -czf /backup/www-$(date +%F).tar.gz /var/www
if [ &? -eq 0 ]; then
    echo "Backup successful"
else
    echo "Backup failed"
fi
Question 97hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A container started with the above Compose configuration fails to set the system time (clock_settime syscall). Which additional capability is required?

Exhibit

Refer to the exhibit.

Exhibit:
{
  "compose": {
    "version": "3.8",
    "services": {
      "app": {
        "image": "myapp:latest",
        "cap_add": ["NET_ADMIN"],
        "cap_drop": ["ALL"]
      }
    }
  }
}
Question 98easymultiple choice
Read the full Scripting, Containers and Automation explanation →

A systems administrator writes a Bash script named 'backup.sh' and wants it to run with the Bash shell. Which line should appear first in the script?

Question 99mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

An administrator needs to run a script '/usr/local/bin/cleanup.sh' every day at 2:30 AM. Which crontab entry is correct?

Question 100hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A Docker container using port 8080 fails to start with the error 'port is already allocated'. Which command should the administrator use to identify the process using that port?

Question 101easymultiple choice
Read the full Scripting, Containers and Automation explanation →

After writing a script, the administrator cannot execute it with './script.sh'. The permissions are '-rw-rw-r--'. Which command makes the script executable?

Question 102mediummultiple choice
Read the full Ansible explanation →

An Ansible playbook includes the following task: 'ansible.builtin.service: name=nginx state=restarted'. However, the playbook fails with 'module not found'. What is the most likely cause?

Question 103hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A DevOps engineer wants to reduce the size of a Docker image by combining build stages. Which Dockerfile feature should be used?

Question 104easymultiple choice
Read the full Scripting, Containers and Automation explanation →

A script named 'test.sh' contains '#!/bin/bash' and is located in the current directory. Which command runs the script in the current shell environment without forking a subshell?

Question 105mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

An administrator wants to run a script every Monday at 3:00 PM using a systemd timer. Which unit file configuration is correct for the timer?

Question 106hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A Kubernetes pod has a container that fails with CrashLoopBackOff. The administrator runs 'kubectl logs pod-name' but sees no output. What is the most likely cause?

Question 107mediummulti select
Read the full Scripting, Containers and Automation explanation →

Which TWO container networking modes allow a container to have its own IP address on the host network? (Choose TWO.)

Question 108hardmulti select
Read the full Scripting, Containers and Automation explanation →

Which THREE of the following are commonly used configuration management and automation tools in the Linux ecosystem? (Choose THREE.)

Question 109easymulti select
Read the full Scripting, Containers and Automation explanation →

Which TWO of the following are valid methods for debugging a Bash script? (Choose TWO.)

Question 110mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

An administrator views the exhibit output. Which command should be used first to investigate why sshd failed?

Network Topology
# systemctl list-unitstype=servicestate=failedRefer to the exhibit.UNIT LOAD ACTIVE SUB DESCRIPTION2 loaded units listed.
Question 111hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

Given the Dockerfile in the exhibit, which best practice is being violated?

Exhibit

Refer to the exhibit.

FROM ubuntu:20.04
RUN apt-get update
RUN apt-get install -y python3
COPY app.py /app/
CMD ["python3", "/app/app.py"]
Question 112easymultiple choice
Read the full Scripting, Containers and Automation explanation →

The script in the exhibit runs successfully but the administrator expects it to indicate success. What change should be made?

Exhibit

Refer to the exhibit.

#!/bin/bash
# Script to print system info
system_info=$(uname -a)
echo "System: $system_info"
exit 1
Question 113mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A sysadmin wants to run a containerized web application using Podman. The container needs to persist data across restarts. Which approach ensures data persistence?

Question 114easymultiple choice
Read the full Scripting, Containers and Automation explanation →

Which command is used to convert a file to uppercase?

Question 115hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A script needs to iterate over all .txt files in a directory. Which loop structure correctly implements this?

Question 116mediummultiple choice
Study the full Python automation breakdown →

Which shebang ensures maximum portability across systems for a Python script?

Question 117easymultiple choice
Read the full Scripting, Containers and Automation explanation →

Which command will show the current running processes in real time?

Question 118hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A sysadmin needs to set a default gateway for a network interface. Which command(s) accomplish this?

Question 119mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

Which command will display the disk usage of each file and directory in the current directory?

Question 120hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

Which command will show the environment variables for a specific process?

Question 121easymultiple choice
Read the full Scripting, Containers and Automation explanation →

Which command will create a compressed tar archive of a directory?

Question 122mediummulti select
Read the full Scripting, Containers and Automation explanation →

Which TWO options are valid ways to pass environment variables to a Docker container?

Question 123easymulti select
Read the full Scripting, Containers and Automation explanation →

Which TWO commands are used to view a file page by page?

Question 124hardmulti select
Read the full Scripting, Containers and Automation explanation →

Which THREE tools are commonly used for configuration management?

Question 125easymultiple choice
Read the full Scripting, Containers and Automation explanation →

The sysadmin receives the error shown in the exhibit. What is the most likely fix?

Exhibit

Refer to the exhibit.

$ cat config.yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx
    resources:
      requests:
        memory: "256Mi"
        cpu: "250m"

$ kubectl apply -f config.yaml
Error: The Pod "nginx" is invalid: spec.containers[0].resources.limits: Required value: must specify limits for cpu and memory
Question 126hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A sysadmin runs the command and sees the exhibit output. What is the most likely cause of the db pod's status?

Exhibit

Refer to the exhibit.

$ kubectl get pods
NAME                        READY   STATUS    RESTARTS   AGE
webapp-6b9f5b7c8d-2x7ht    1/1     Running   0          10m
webapp-6b9f5b7c8d-3y8iu    1/1     Running   0          10m
db-7d4f6c8e9f-1a2b3        0/1     CrashLoopBackOff  5   15m
Question 127mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A company runs a critical web application on a single server using Docker containers. The application consists of a web frontend container and a backend API container. Recently, the server ran out of disk space due to Docker logs and temporary images. The sysadmin is tasked with automating cleanup to prevent recurrence. The solution must not disrupt running containers. Which approach should be taken?

Question 128easymultiple choice
Read the full Scripting, Containers and Automation explanation →

A Linux administrator writes a script that uses bash-specific features like arrays and process substitution. Which shebang should be used?

Question 129mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

A cron job runs a script that produces output, but the administrator does not receive the expected email notification. Which is the most likely cause?

Question 130hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A containerized application is consuming excessive memory on a Linux host running Podman. Which command sets a memory limit of 512 megabytes when running a container?

Question 131mediummultiple choice
Read the full Ansible explanation →

An Ansible playbook fails with a syntax error. Which command validates the playbook syntax without running it?

Question 132easymultiple choice
Read the full Scripting, Containers and Automation explanation →

A system administrator needs to run a script every 15 minutes. Which systemd unit type is used to schedule this?

Question 133hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A DevOps team wants to automatically run tests before every commit in a local Git repository. Which Git hook should be used?

Question 134mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

An administrator uses Podman containers and wants them to start automatically when the host boots. Which method should be used?

Question 135easymulti select
Study the full Python automation breakdown →

A Linux administrator writes a Python script to parse configuration files. Which TWO practices improve security and portability? (Select TWO.)

Question 136hardmulti select
Read the full Scripting, Containers and Automation explanation →

A security policy requires that containers run with minimal privileges. Which THREE measures should be implemented? (Select THREE.)

Question 137easymulti select
Read the full Scripting, Containers and Automation explanation →

An administrator wants to ensure a critical monitoring script runs every day at 2 AM and sends output to a log file. Which THREE items are essential in the crontab entry? (Select THREE.)

Question 138mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

You are a Linux administrator at a company that runs a web application in Docker containers on a single host. The application consists of a front-end container (nginx) and a back-end container (node.js). Recently, after a system update, the front-end container fails to start with the error: 'Error response from daemon: driver failed programming external connectivity on endpoint frontend: (iptables failed: iptables --wait -t filter -A DOCKER ! -i docker0 -o docker0 -p tcp -d 172.17.0.2 --dport 80 -j ACCEPT: iptables: No chain/target/match by that name)'. Which action should you take to resolve the issue?

Question 139hardmultiple choice
Read the full Ansible explanation →

Your organization uses Ansible for configuration management across 500 servers. The management server is a Linux workstation. You have written a playbook to deploy a new monitoring agent. The playbook works on all test machines but fails on production machines at the 'Gather Facts' stage with the error: 'fatal: [server1]: FAILED! => {"msg": "Timed out waiting for privilege escalation prompt: become method 'sudo' requires a password" }'. All production servers have the same sudoers configuration. You have confirmed that the user 'ansible' has passwordless sudo configured correctly. What is the most likely cause?

Question 140easymultiple choice
Read the full Scripting, Containers and Automation explanation →

You are a Linux system administrator for a small company. You have written a BASH script that checks disk usage and sends an email alert if any partition exceeds 90% usage. The script works when run manually but does not produce alerts when run via cron. Which of the following is the most likely cause?

Question 141mediummultiple choice
Read the full Scripting, Containers and Automation explanation →

You are managing a containerized microservices environment using Podman. One of the services needs to access a PostgreSQL database running in a separate container. The database container is named 'db' and uses the default bridge network. The application container is launched with the command: podman run -d --name app --network host myapp. The application fails to connect to the database using the hostname 'db'. Which change should you resolve the issue?

Question 142hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

You are a DevOps engineer managing a Git repository for a large development team. Your CI/CD pipeline runs automated tests on every push. Recently, developers have been pushing commits that break the build. You need to enforce that all commits pass the tests before being pushed to the remote repository. Which Git hook should you implement on the client side?

Question 143mediummulti select
Read the full Scripting, Containers and Automation explanation →

A system administrator wants to automate server configuration and management across multiple Linux hosts. Which TWO tools are configuration management solutions designed for this purpose? (Choose two.)

Question 144easymultiple choice
Read the full Scripting, Containers and Automation explanation →

An administrator needs to run a backup script every day at 2:00 AM. The script is located at /usr/local/bin/backup.sh and is executable. The administrator considers several methods to schedule this task. Which method should the administrator use to ensure the script runs at exactly 2:00 AM every day without additional configuration overhead?

Question 145easymultiple choice
Read the full Scripting, Containers and Automation explanation →

A DevOps engineer is writing a Bash script to check if the configuration file /etc/myapp.conf exists and is readable. The script must exit with code 0 if the file is readable, and exit with code 1 otherwise. The script will be used on systems with Bash as the default shell. Which code snippet correctly implements this logic using the most efficient syntax available in Bash?

Question 146mediummultiple choice
Read the full network assurance explanation →

A developer runs a web application inside a Podman container. The application logs HTTP requests to stdout in JSON format. The operations team wants to centralize these logs by forwarding them to a remote syslog server. The administrator considers several approaches. Which approach is the most reliable and recommended way to forward container logs to syslog without modifying the application?

Question 147hardmultiple choice
Read the full Ansible explanation →

A system administrator is using Ansible to deploy a web application across multiple servers. The playbook uses a variable `app_version` defined in a group_vars file for the `webservers` group. The playbook fails with the error: 'ERROR! 'app_version' is undefined'. The administrator confirms that the variable is correctly spelled and defined in `/etc/ansible/group_vars/webservers`. The playbook runs successfully on the Ansible control node but fails on all managed nodes. What is the most likely cause of this error?

Question 148hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

A Linux server runs a critical service managed by a systemd service unit. The administrator needs to configure the service to automatically restart if it crashes, but only up to 3 times within a 30-second window. If the service restarts more than 3 times in 30 seconds, systemd should stop attempting to restart and leave the service in a failed state. Which set of directives should be added to the [Service] section of the unit file to achieve this behavior?

Question 149mediummulti select
Read the full Scripting, Containers and Automation explanation →

A Linux administrator uses Podman for container management. Which TWO commands display a list of currently running containers?

Question 150hardmultiple choice
Read the full Scripting, Containers and Automation explanation →

Refer to the exhibit. The administrator receives an email that a cron job failed. What is the most likely cause?

Exhibit

Feb 12 02:00:01 hostname CRON[1234]: (root) CMD (/usr/local/bin/backup.sh) -> /usr/local/bin/backup.sh: line 3: syntax error near unexpected token `fi'
Question 151easymultiple choice
Read the full Scripting, Containers and Automation explanation →

Sarah is a Linux systems administrator for a company that runs a web application inside a Podman container. The container is launched using a systemd service file on a Red Hat Enterprise Linux 8 server. The service file is located at /etc/systemd/system/webapp.service and includes an ExecStart directive that runs `podman run -d --name webapp -p 80:80 nginx`. The server was recently rebooted for kernel updates. After the reboot, the web application is not responding. Sarah logs in and runs `systemctl status webapp.service`, which shows the service is 'disabled' and 'inactive'. She wants to ensure that the container starts automatically after every future reboot. What should Sarah do?

Practice tests

Scored 10-question sessions with instant feedback and explanations.

XK0-005 Practice Test 1 — 10 Questions→XK0-005 Practice Test 2 — 10 Questions→XK0-005 Practice Test 3 — 10 Questions→XK0-005 Practice Test 4 — 10 Questions→XK0-005 Practice Test 5 — 10 Questions→XK0-005 Practice Exam 1 — 20 Questions→XK0-005 Practice Exam 2 — 20 Questions→XK0-005 Practice Exam 3 — 20 Questions→XK0-005 Practice Exam 4 — 20 Questions→Free XK0-005 Practice Test 1 — 30 Questions→Free XK0-005 Practice Test 2 — 30 Questions→Free XK0-005 Practice Test 3 — 30 Questions→XK0-005 Practice Questions 1 — 50 Questions→XK0-005 Practice Questions 2 — 50 Questions→XK0-005 Exam Simulation 1 — 100 Questions→

Practice by domain

Each domain maps to a weighted exam section. Focus on the domain where you are weakest.

SecurityTroubleshootingScripting, Containers and AutomationSystem Management

Practice by scenario

Filter questions by type — troubleshooting, exhibit, drag-and-drop, PBQ, ACLs, OSPF, and more.

Browse scenarios→

Continue studying

All Scripting, Containers and Automation setsAll Scripting, Containers and Automation questionsXK0-005 Practice Hub