Courseiva
Essential Tools →easyMultiple Choice

EX200 Essential Tools Practice Question

A user needs to view the last 15 lines of a log file that is constantly being updated. Which command should they use?

⚠ Common exam trap

Test-takers frequently confuse `tail -f` (which follows the file in real time) with `tail -n` (which shows a specific number of lines from the end), leading them to choose option B when the requirement is for a static view of the last lines.

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

✓

tail -n 15 /var/log/messages

The `tail -n 15 /var/log/messages` command displays the last 15 lines of the specified log file without following it. This meets the requirement to view the last 15 lines of a file that is constantly being updated, as it provides a static snapshot of the most recent entries.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    tail -n 15 /var/log/messages

    Why this is correct

    tail -n 15 /var/log/messages is correct because tail reads from the end of a file, and the -n 15 flag limits output to exactly the last 15 lines. Unless told otherwise, tail prints the final 10 lines; -n overrides this default to match the requested count. The command then exits, providing a clean, one-time snapshot of the most recent entries in the system log.

  • ✗

    tail -f /var/log/messages

    Why it's wrong here

    tail -f /var/log/messages does not simply show the last 15 lines; the -f (follow) flag makes tail output the last 10 lines by default and then remain attached to the file, continuously printing every new line that is appended. This means the command never terminates on its own, making it useless for a one-off requirement of viewing exactly 15 lines, and it floods the terminal with ongoing updates instead.

  • ✗

    cat /var/log/messages

    Why it's wrong here

    cat /var/log/messages prints the entire contents of the file from the very first line to the last, which for a long-running system log can be thousands of lines or more. It does not apply any line-count limit, so it far exceeds the requested 15 lines and could overwhelm the terminal or scroll those last lines off the screen entirely.

  • ✗

    head -15 /var/log/messages

    Why it's wrong here

    head -15 /var/log/messages displays the first 15 lines of the log file, which correspond to the oldest records in the file, not the newest. This is the functional opposite of what the user wants; the last lines of a log are typically the most relevant for troubleshooting, and head provides no option to count from the end.

About these practice questions

One of 427 original EX200 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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 EX200 practice question is part of Courseiva's free Red Hat 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 EX200 exam.