220-1102 exam dumps

220-1102 practice question 242 of 828

A+ Core 2. Associate level, CompTIA. Free question with the correct answer and a full explanation.

220-1102 Question 242

Single answergrep

A Linux technician is troubleshooting repeated failed SSH login attempts on a workstation. The technician needs to quickly display only the lines in /var/log/auth.log that contain the exact text "Failed password" so they can review the relevant events. Which command should the technician use?

  1. A

    grep "Failed password" /var/log/auth.log

  2. B

    grep /var/log/auth.log "Failed password"

  3. C

    cat /var/log/auth.log | grep -v "Failed password"

  4. D

    find "Failed password" /var/log/auth.log

Show answer and explanation

Correct answer: A

Explanation

This question tests practical use of grep in a real troubleshooting scenario. In Linux, grep is commonly used to search log files for specific events, such as authentication failures. The basic syntax is grep "pattern" filename. This makes it a standard tool for reviewing logs like /var/log/auth.log during security or access-related investigations. By contrast, grep -v excludes matching lines, and find searches for filesystem objects rather than text inside files. This aligns with common Linux command-line usage documented in grep manual pages (man grep) and standard administrative best practices for log review.

  • A. Correct.

    Correct. The grep command searches a file for matching text patterns. Using grep "Failed password" /var/log/auth.log displays only the lines in that log file that contain the specified phrase, which is exactly what the technician needs for targeted troubleshooting.

  • B. Incorrect.

    Incorrect. This reverses the normal grep syntax. grep expects the search pattern first and then the file name. Entering the file path before the search string would cause the command to be interpreted incorrectly and would not return the desired results.

  • C. Incorrect.

    Incorrect. The -v option tells grep to invert the match, meaning it shows lines that do NOT contain "Failed password." A technician might choose this if they confuse filtering with exclusion, but it would hide the failed login entries instead of displaying them.

  • D. Incorrect.

    Incorrect. The find command is used to locate files and directories, not search within file contents for text strings. This is a common misconception for those who confuse file searching with content searching.

Timed practice exam

Take a 220-1102 practice test under exam conditions

90 questions in 90 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam