Courseiva
easyMultiple ChoiceObjective-mapped

XK0-006 Practice Question: The script in the exhibit runs successfully but…

Exhibit

Refer to the exhibit.

#!/bin/bash
# Script to print system info
system_info=$(uname -a)
echo "System: $system_info"
exit 1

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

⚠ Common exam trap

CompTIA often tests the fundamental distinction between exit codes 0 and 1, where candidates may mistakenly think that 'exit 1' is correct for a successful script or that variable naming or quoting affects the exit status.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Change 'exit 1' to 'exit 0'

The script uses 'exit 1' to terminate, which indicates a failure or error condition to the shell. The administrator expects the script to indicate success, so the exit code must be changed to 'exit 0', which is the standard Unix/Linux convention for successful execution. Exit codes are how scripts communicate their status to the calling process, and only exit 0 means success.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Replace $system_info with just system_info

    Why it's wrong here

    Would print literal string instead of variable.

  • Change 'exit 1' to 'exit 0'

    Why this is correct

    Zero exit code indicates success.

  • Change the variable name to SYSTEM_INFO

    Why it's wrong here

    Does not affect exit code.

  • Change 'exit 1' to 'exit 0' and remove the quotes around $system_info

    Why it's wrong here

    Quotes are fine, but removing them could cause word splitting issues.

About these practice questions

This XK0-006 question is part of Courseiva's 979-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.