Courseiva
hardMultiple ChoiceObjective-mapped

XK0-006 Practice Question: A senior administrator is troubleshooting a shell…

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?

⚠ Common exam trap

Many exam-takers think the shebang line must be on the first line (Option A) is the issue, but CompTIA tests the subtle Windows line-ending problem (\r) that causes the interpreter path to be invalid, which is a common real-world pitfall when scripts are edited in Windows environments and transferred to Linux.

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

The script contains carriage return characters (\r).

Carriage return characters (\r) are a common issue when scripts are edited on Windows and then transferred to Linux. The shebang line #!/bin/bash expects a Unix-style line ending (LF), but \r characters cause the shell to interpret the command interpreter as '/bin/bash\r', which is not a valid executable path. This results in a 'No such file or directory' error when the script is invoked as ./script.sh, even though permissions are correct.

Answer analysis

Option-by-option breakdown

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

  • The shebang line is not on the first line.

    Why it's wrong here

    Shebang must be first line, but that would cause an error.

  • The script contains carriage return characters (\r).

    Why this is correct

    Can cause 'No such file or directory'.

  • The script uses #!/bin/sh instead of bash.

    Why it's wrong here

    That is a valid shebang.

  • The script starts with a byte order mark (BOM).

    Why it's wrong here

    BOM is valid in UTF-8 scripts.

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.