Courseiva
easyMultiple Choice

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

    Replacing $system_info with just system_info would print the literal word rather than the variable's value, so the intended success message would not appear. It is tempting because removing the dollar sign looks like a syntax fix, but the correct change concerns the exit status or output logic, not the variable reference itself.

  • ✓

    Change 'exit 1' to 'exit 0'

    Why this is correct

    Exit codes signal process outcome to the calling shell: zero denotes success, any non-zero value indicates failure. The script currently returns 1, so the administrator sees an error despite correct execution. Changing it to exit 0 satisfies the stem's requirement that the script indicate success.

  • ✗

    Change the variable name to SYSTEM_INFO

    Why it's wrong here

    Renaming the variable to SYSTEM_INFO changes nothing about the script's behaviour; the success indication depends on the exit status or the message printed, not the variable's casing. It is tempting because shell variables are case-sensitive, but the existing name is referenced consistently, so the rename is cosmetic and leaves the actual fault untouched.

  • ✗

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

    Why it's wrong here

    Removing the quotes around $system_info would break the variable expansion, and changing exit 1 to exit 0 alters the exit status rather than the success message the script should print. The exit code is tempting because non-zero status signals failure, but the stem concerns the script's output, not its return value.

About these practice questions

This XK0-006 question is part of Courseiva's 781-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.