Question

Difficulty: MediummacOS and Linux Operating System Features and Tools

A Linux system administrator needs to scan through the contents of multiple log files in the `/var/log` directory to locate lines containing the string "AUTHENTICATION_FAILURE". Which command-line tool is specifically designed to search file contents for matching text patterns?

  1. grepAnswer
  2. B
    find
  3. C
    cat
  4. D
    ls

Answer

grep
The grep command searches text files or command output for matching lines using strings or regular expressions. It is the primary tool for searching text within files in Linux and macOS environments.

Step-by-Step Solution

1
Identify the administrative task required
The administrator must search inside files for specific text content ("AUTHENTICATION_FAILURE").
Choosing the correct Linux utility requires determining whether the search target is file content or file metadata.
2
Evaluate the available Linux CLI commands
The grep utility processes input streams or files line by line and prints lines that match a specified pattern.
grep (Global Regular Expression Print) is the standard Unix tool for content-based text searching.

Key Concept

Linux command-line utilities for file and text searching
Rate this question