Courseiva
System ManagementmediumMultiple ChoiceObjective-mapped

XK0-006 System Management Practice Question

A technician needs to search a log file for lines containing either 'ERROR' or 'FATAL' and display the line numbers. Which command accomplishes this?

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

grep -n -E 'ERROR|FATAL' logfile

grep -n -E 'ERROR|FATAL' logfile uses extended regex with alternation and -n for line numbers. -i ignores case, but the stem does not mention case-insensitive; -v inverts match; -r is recursive.

Answer analysis

Option-by-option breakdown

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

  • grep -v -E 'ERROR|FATAL' logfile

    Why it's wrong here

    -v inverts match, showing lines without ERROR/FATAL.

  • grep -r -n 'ERROR|FATAL' logfile

    Why it's wrong here

    -r is for recursive; '|' literal without -E.

  • grep -n -E 'ERROR|FATAL' logfile

    Why this is correct

    Correct: -n for line numbers, -E for extended regex.

  • grep -i 'ERROR|FATAL' logfile

    Why it's wrong here

    -i ignores case but does not show line numbers and '|' is literal without -E.

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 →

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.