nerdexam
GIAC

GSEC · Question #235

GSEC Question #235: Real Exam Question with Answer & Explanation

The correct answer is C. cat /var/log/messages | grep error. Piping cat output into grep filters the log file to display only lines containing the search term, making it the correct way to find error messages.

Question

You work as a Network Administrator for Perfect Solutions Inc. The company has a Linux-based network. You are required to search for the error messages in the /var/log/messages log file. Which of the following commands will you use to accomplish this?

Options

  • Aps /var/log/messages
  • Bcat /var/log/messages | look error
  • Ccat /var/log/messages | grep error
  • Dcat /var/log/messages

Explanation

Piping cat output into grep filters the log file to display only lines containing the search term, making it the correct way to find error messages.

Common mistakes.

  • A. The ps command displays currently running processes and cannot read or search file contents.
  • B. The look command performs prefix-based searching in sorted word files and is not designed for filtering arbitrary log file content.
  • D. cat /var/log/messages alone outputs the entire file with no filtering, so error messages would not be isolated from the rest of the output.

Concept tested. Linux grep command for searching log files

Reference. https://man7.org/linux/man-pages/man1/grep.1.html

Community Discussion

No community discussion yet for this question.

Full GSEC Practice