Question 505 of 527
Create simple shell scriptsmediumMultiple ChoiceObjective-mapped

Quick Answer

The answer is that using the test command `[ ]` around a command condition causes the condition to always be true. This happens because the `test` builtin evaluates the contents of the brackets as a string, not as a command; when you write `[ systemctl is-active httpd ]`, the shell sees the non-empty string "systemctl" inside the brackets, which `test` interprets as a true condition regardless of the actual service status. On the Red Hat Certified System Administrator EX200 exam, this is a classic trap that tests your understanding of how shell scripts evaluate conditions—the correct approach is to use the command directly as the condition, like `if systemctl is-active httpd; then`, which checks the command's exit code. A reliable memory tip: if you see brackets around a command, you are testing the string, not the exit status; for command conditions, leave the brackets out and let the command speak for itself.

EX200 Create simple shell scripts Practice Question

This EX200 practice question tests your understanding of create simple shell scripts. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

Network Topology
if systemctl is-activequiet $SERVICERefer to the exhibit.```bash#!/bin/bash# Script: check_service.shSERVICE="httpd"thenecho "$SERVICE is running"elsesystemctl restart $SERVICEecho "$SERVICE was restarted"fi```

Refer to the exhibit. A junior admin runs this script as root, but it always prints 'httpd is running' even when httpd is stopped. What is the most likely cause?

Clue words in this question

Noticing these words before you look at the options changes how you read each choice.

  • Clue: "most likely"

    Why it matters: Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

  • Clue: "always"

    Why it matters: Absolute qualifier. An answer using 'always' is only correct if there are genuinely no exceptions — absolute statements are often wrong in networking.

Question 1mediummultiple choice
Full question →
Network Topology
if systemctl is-activequiet $SERVICERefer to the exhibit.```bash#!/bin/bash# Script: check_service.shSERVICE="httpd"thenecho "$SERVICE is running"elsesystemctl restart $SERVICEecho "$SERVICE was restarted"fi```

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 the test command `[` instead of directly using the command as the condition, causing the condition to always be true.

Option D is correct because when a command is used as a condition inside `[ ]`, the `test` builtin evaluates the exit status of the command inside the brackets, not the command itself. In this script, `[ systemctl is-active httpd ]` always returns true (exit code 0) because `[` treats the string "systemctl" as a non-empty string, which is always true. The correct syntax is to use the command directly as the condition: `if systemctl is-active httpd; then`.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

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 is not executable and is run with `sh script.sh`, causing the shebang to be ignored.

    Why it's wrong here

    Even with sh, the script runs; the shebang is ignored but the bug still exists.

  • The variable SERVICE is misspelled as "HTTPD" in the condition.

    Why it's wrong here

    The exhibit shows consistent spelling.

  • The `systemctl` command requires root privileges, and the script is run as a non-root user.

    Why it's wrong here

    The stem states the script is run as root.

  • The script uses the test command `[` instead of directly using the command as the condition, causing the condition to always be true.

    Why this is correct

    `[ systemctl ... ]` always evaluates to true because it tests the string.

    Clue confirmation

    The clue words "most likely", "always" in the question point toward this answer.

    Related concept

    Read the scenario before looking for a memorised answer.

Common exam traps

Common exam trap: answer the scenario, not the keyword

The trap here is that candidates mistakenly think the `[ ]` syntax is required for all conditions, not realizing that `[` is actually a command that evaluates its arguments as a test expression, not as a command to execute.

Trap categories for this question

  • Command / output trap

    The exhibit shows consistent spelling.

Detailed technical explanation

How to think about this question

The `[` command (test) evaluates expressions based on its arguments; when given a single string like "systemctl", it checks if the string is non-empty, which is always true. The correct approach is to use the command directly in the `if` statement without brackets, which evaluates the command's exit status. This is a common pitfall for beginners who assume `[ command ]` runs the command, when in fact it just tests the string.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A junior network technician can log in to a core router but cannot reach the enable prompt or configuration mode. The AAA server is authenticating the login — but the authorisation policy only grants privilege level 1, not 15. Authentication (who you are) is working; authorisation (what you can do) is not.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related EX200 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free EX200 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this EX200 question test?

Create simple shell scripts — This question tests Create simple shell scripts — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: The script uses the test command `[` instead of directly using the command as the condition, causing the condition to always be true. — Option D is correct because when a command is used as a condition inside `[ ]`, the `test` builtin evaluates the exit status of the command inside the brackets, not the command itself. In this script, `[ systemctl is-active httpd ]` always returns true (exit code 0) because `[` treats the string "systemctl" as a non-empty string, which is always true. The correct syntax is to use the command directly as the condition: `if systemctl is-active httpd; then`.

What should I do if I get this EX200 question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Are there clue words in this question I should notice?

Yes — watch for: "most likely", "always". Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 11, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This EX200 practice question is part of Courseiva's free Red Hat 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 EX200 exam.