XK0-006 tail command Practice Question
An administrator wants to view the last 20 lines of a log file and continue to watch for new entries. Which command should be used?
⚠ Common exam trap
Candidates often assume tail -20 will continue to watch for new entries, but the -20 option only sets the line count and does not enable follow mode. The -f flag is required to keep watching the file.
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 -f
The command tail -f follows a file and continues to display new entries as they are appended. Although tail -f by default shows only the last 10 lines, it is the only listed option that meets the 'continue to watch' requirement. To view exactly the last 20 lines while following, the full command would be tail -n 20 -f (or tail -20f), but among the provided options, tail -f is the correct choice.
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 -20
Why it's wrong here
Correct. tail -20 shows the last 20 lines, and with -f it can also watch for new entries.
- ✗
head -20
Why it's wrong here
head -20 shows the first 20 lines, not the last.
- ✓
tail -f
Why this is correct
tail -f shows the last 10 lines by default and follows, but does not meet the 20-line requirement without adding -n20.
- ✗
less -N
Why it's wrong here
less -N displays a file with line numbers but does not follow new entries.
Go deeper
Related to this question
About these practice questions
Courseiva writes every XK0-006 question from scratch — 979 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
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.