Courseiva
System Management →mediumMultiple Choice

XK0-006 System Management Practice Question

A system administrator wants to view the last 10 lines of a log file and also save those lines to another file for analysis. Which command should the administrator use?

⚠ Common exam trap

XK0-006 often tests the difference between head and tail, and the correct usage of tee with pipes; candidates may confuse head with tail or misuse redirection syntax.

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 10 file | tee output.txt

The command 'tail -n 10 file | tee output.txt' displays the last 10 lines of the file and simultaneously writes those lines to output.txt. The tail command extracts the last 10 lines, and tee duplicates the output to both the terminal and the specified file.

Answer analysis

Option-by-option breakdown

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

  • ✗

    head -n 10 file | tee output.txt

    Why it's wrong here

    head -n 10 reads the first ten lines, not the last ten, so the wrong content is both displayed and written. It is tempting because tee correctly duplicates output to the terminal and file, and head is the right command whenever the requirement is the beginning of a file.

  • ✗

    cat file | tee output.txt

    Why it's wrong here

    cat outputs the entire file, so all lines are displayed and saved rather than only the last ten. It is tempting because tee correctly splits output to stdout and output.txt, and cat piped to tee is the right pattern when the whole file must be captured.

  • ✓

    tail -n 10 file | tee output.txt

    Why this is correct

    tail -n 10 extracts the final ten lines, and piping into tee writes them to output.txt while also displaying them on stdout. Redirection with > would suppress terminal output, and tee -a would append rather than create, so this pipeline satisfies both viewing and saving.

  • ✗

    tee output.txt < tail -n 10 file

    Why it's wrong here

    The shell parses redirection before execution, so '< tail -n 10 file' attempts to read a file literally named 'tail', failing rather than piping. It is tempting because tee with a file argument does write and display, and this form would work if the input were supplied through a pipe instead.

About these practice questions

This XK0-006 question is part of Courseiva's 781-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 and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official CompTIA exam blueprint

This XK0-006 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 XK0-006 exam.