hardMultiple SelectObjective-mapped
XK0-006 Practice Question: A system administrator is troubleshooting a bash…
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.)
⚠ Common exam trap
CompTIA often tests the misconception that cron runs scripts with the same environment as the user's interactive shell, leading candidates to overlook PATH and interactive command issues in favor of user ID or interpreter differences.
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 uses interactive commands
Interactive commands (e.g., `read`, `select`, or commands that require a TTY) fail when run from cron, as cron does not allocate a terminal. The script expects user input or terminal interaction, which is not available in the cron environment, causing it to hang or error out. Option E is correct because cron runs with a minimal PATH (often `/usr/bin:/bin`), so the script may fail to locate commands that are found in the user's interactive shell PATH (e.g., `/usr/local/bin`).
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 script uses interactive commands
Why this is correct
Commands like read, vi, or those requiring a terminal fail non-interactively.
- ✗
The script uses a different shell interpreter
Why it's wrong here
The shebang line defines the interpreter; cron uses the same if defined.
- ✗
The script uses absolute paths
Why it's wrong here
Using absolute paths reduces PATH-related issues and would not cause failure.
- ✗
The script runs with a different user ID
Why it's wrong here
If the same user runs both, user ID is same. Even if different, it would typically cause permission errors, not complete failure.
- ✓
Different PATH environment variable
Why this is correct
Cron typically has a limited PATH, causing commands to not be found unless full paths are used.
Go deeper
Related to this question
Learn chapter
User and Group Administration
Key term
Terminal
A terminal is a text-based interface that allows users to communicate with a computer's operating system by typing commands.
Key term
Bash
Bash is a command-line interpreter that lets users interact with an operating system by typing text commands instead of clicking icons.
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 →
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.