LFCS Essential Commands Practice Question
Which THREE of the following commands can be used to search for a string in multiple files and display the matching lines?
⚠ Common exam trap
Watch out — candidates often confuse file-location commands like `find` with content-search commands, or assume that `sort` can filter lines based on a pattern, when it only reorders 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
✓
ack 'pattern' /path
`ack` is a Perl-based grep replacement that recursively searches for a pattern in files under a given path, displaying matching lines by default. It is designed for source code and text files, making it a valid tool 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.
- ✗
find /path -name '*.txt' -type f
Why it's wrong here
Finds files, not content.
- ✓
ack 'pattern' /path
Why this is correct
Similar to grep, recursive.
- ✓
grep -r 'pattern' /path
Why this is correct
Recursive search.
- ✓
rg 'pattern' /path
Why this is correct
ripgrep searches for patterns.
- ✗
sort /path/file
Why it's wrong here
Sorts lines, does not search.
Go deeper
Related to this question
About these practice questions
This LFCS question is part of Courseiva's 507-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 →
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.