LFCS Essential Commands Practice Question
To display the first 10 lines of a file named 'log.txt', which command is correct?
⚠ Common exam trap
Candidates often confuse `head` with `tail` or assume `less` or `cat` are appropriate for displaying only the first few lines, when in fact `head` is the specific command for that purpose.
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 log.txt
The `head` command is designed to display the first 10 lines of a file by default. Running `head log.txt` outputs the first 10 lines of the file without any additional options, making it the correct choice for this task.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
less log.txt
Why it's wrong here
Opens the file in a pager; does not automatically show only first 10 lines.
- ✗
tail log.txt
Why it's wrong here
Shows the last 10 lines by default.
- ✓
head log.txt
Why this is correct
Outputs the first 10 lines by default.
- ✗
cat log.txt
Why it's wrong here
Outputs the entire file.
Go deeper
Related to this question
About these practice questions
One of 507 original LFCS 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 by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This LFCS practice question is part of Courseiva's free Linux Foundation 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 LFCS exam.