XK0-006 System Management Practice Question
A user needs to view the first 15 lines of a large log file. Which command is most appropriate?
⚠ Common exam trap
XK0-006 often tests the difference between head and tail, and the proper syntax for limiting lines; candidates may confuse -n with other options or choose cat | head unnecessarily.
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
✓
head -n 15 filename
The command 'head -n 15 filename' is the most appropriate and efficient way to view the first 15 lines of a file. The head command is designed for this purpose, and the -n option specifies the number of lines. This is a standard Linux command and is more direct than piping cat to head.
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 15 filename
Why this is correct
head outputs the beginning of a file, and -n 15 limits that output to exactly 15 lines, directly satisfying the requirement to view the first 15 lines. tail would show the end, and cat would dump the entire large log.
- ✗
cat filename | head -n 15
Why it's wrong here
The pipeline `cat filename | head -n 15` works correctly but is unnecessarily inefficient: `head` can open the file directly, so the extra `cat` process adds a redundant read and pipe overhead without any benefit. It is tempting because many users habitually pipe `cat` into other commands as a generic pattern for feeding file content into a filter, and in scenarios where the file must be processed by multiple commands in sequence (e.g., `cat file | grep pattern | sort`), the `cat` is justified as the initial input source.
- ✗
less -N 15 filename
Why it's wrong here
less -N numbers every displayed line; the 15 is not a line count, so the file opens at line one without limiting output to 15 lines. It is tempting because less is the standard pager for browsing large files, and would be correct if the user wanted to page through the whole log with line numbers.
- ✗
tail -n 15 filename
Why it's wrong here
tail prints the last lines of a file, so it returns the final 15 entries of the log rather than the first 15 the user requested. It is tempting because tail is the natural tool for reading recent log activity, and would be correct if the user needed the most recent entries instead.
Go deeper
Related to this question
Learn chapter
User and Group Administration
Key term
Linux
Linux is an open-source operating system that manages computer hardware and software, widely used in servers, desktops, and embedded systems.
Key term
User
A user is any person, system, or device that interacts with an IT service, resource, or identity system, typically authenticated through credentials and authorized to perform specific actions.
About these practice questions
One of 781 original XK0-006 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 →
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.