Courseiva
easyMultiple ChoiceObjective-mapped

XK0-006 Practice Question: What does the `set -x` command do when placed at…

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

⚠ Common exam trap

Test-takers frequently confuse `set -x` with `set -e` (exit on error) or `set -u` (treat unset variables as error), because all three are common debugging options but serve distinct purposes.

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

Displays each command before executing it

`set -x` enables a shell debugging mode that prints each command (after expansion) to stderr before executing it. This is commonly used in bash scripts to trace execution flow and debug complex logic.

Answer analysis

Option-by-option breakdown

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

  • Enables position parameters

    Why it's wrong here

    Positional parameters are accessed via $1, $2, etc.; set -x does not affect them.

  • Exits the script on error

    Why it's wrong here

    That is the function of set -e, not set -x.

  • Treats unset variables as errors

    Why it's wrong here

    That is the behavior of set -u, not set -x.

  • Displays each command before executing it

    Why this is correct

    Correct. set -x enables debugging output, printing commands and their arguments as they are executed.

About these practice questions

Courseiva writes every XK0-006 question from scratch — 979 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.