Courseiva
mediumMultiple Choice

220-1102 Practice Question: Search for any file in /etc that contains the…

A technician needs to search for any file in /etc that contains the string 'Password' (case-insensitive). Which command should be used?

⚠ Common exam trap

CompTIA often tests the distinction between searching file contents (`grep`) versus searching filenames (`find`, `locate`), and the trap here is that candidates may forget the `-i` flag for case-insensitivity or confuse `grep` with `find`.

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 -ri 'Password' /etc

The `grep -ri` command performs a recursive (`-r`) case-insensitive (`-i`) search for the string 'Password' across all files under the `/etc` directory. This matches the requirement exactly: case-insensitive search for any file containing the string.

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 -r 'Password' /etc

    Why it's wrong here

    grep -r 'Password' /etc is case-sensitive, so it misses files containing 'password' or 'PASSWORD', failing the case-insensitive requirement. It is tempting because recursive grep is the right tool for content searches; adding -i would make it correct.

  • ✓

    grep -ri 'Password' /etc

    Why this is correct

    The `-r` flag makes grep recurse through every subdirectory of /etc, while `-i` ignores case so 'Password', 'password' and 'PASSWORD' all match. This satisfies both stem constraints — searching all files under /etc and matching the string case-insensitively — in a single command.

  • ✗

    find /etc -name '*Password*'

    Why it's wrong here

    find -name matches filenames only, not file contents, so it cannot locate files containing the string 'Password'. It is tempting because find is the standard tool for searching /etc, but it suits locating files by name, size, or permissions rather than by text within them.

  • ✗

    locate Password | grep /etc

    Why it's wrong here

    locate queries a prebuilt filename database and cannot inspect file contents, so it cannot find files containing 'Password'; piping to grep /etc also treats /etc as a filename. It is tempting because locate is fast for filename searches, which suits locating files by name rather than by content.

About these practice questions

This 220-1202 question is part of Courseiva's 687-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 220-1202 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 220-1202 exam.