Courseiva
System Management →mediumMultiple Choice

XK0-006 System Management Practice Question

A Linux administrator wants to search for all occurrences of the word 'ERROR' in log files under /var/log, ignoring case, and also print the line numbers. Which command should be used?

⚠ Common exam trap

XK0-006 often tests grep flag combinations — candidates confuse -v (invert) with -i (ignore case) and -c (count) with -n (line number), or forget that -r is required to recurse into /var/log.

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 -rin 'ERROR' /var/log

The command 'grep -rin ERROR /var/log' combines -r (recursive search through directories), -i (case-insensitive match), and -n (print line numbers). This searches every file under /var/log for 'ERROR' regardless of case and prefixes each match with its line number, exactly matching the requirement.

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 -vi 'ERROR' /var/log

    Why it's wrong here

    The -v flag inverts the match, printing lines that do not contain 'ERROR', and grep given a directory without -r reports an error rather than searching files. It is tempting because -i correctly ignores case, which is genuinely needed here.

  • ✓

    grep -rin 'ERROR' /var/log

    Why this is correct

    The -r flag recurses through every file under /var/log, -i matches 'ERROR' case-insensitively, and -n prefixes each match with its line number. Together these satisfy all three requirements: recursive search, case-insensitive matching, and printed line numbers.

  • ✗

    grep -rn 'ERROR' /var/log

    Why it's wrong here

    Without -i, grep matches 'ERROR' case-sensitively, so 'error' or 'Error' entries are missed. Adding -i performs the case-insensitive match while -r and -n recurse and print line numbers. This command is the right choice when the log casing is known to be consistently uppercase.

  • ✗

    find /var/log -name '*ERROR*'

    Why it's wrong here

    find matches filenames, not file contents, so it cannot locate the word 'ERROR' inside logs nor print matching line numbers. It is tempting because find does traverse /var/log recursively, and would be correct for locating files whose names contain a pattern.

About these practice questions

Courseiva writes every XK0-006 question from scratch — 781 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 and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official CompTIA exam blueprint

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.