LFCS Essential Commands Practice Question
A user wants to find the location of the 'grep' binary. Which command should they use?
⚠ Common exam trap
Many candidates confuse documentation commands (man) or system information commands (uname) with binary location commands, or mistakenly think a recursive grep search is an efficient way to find a binary, when 'which' is the standard, straightforward tool for this task.
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
✓
which grep
The 'which' command is specifically designed to locate the binary (executable) of a command by searching the directories listed in the user's PATH environment variable. Option B, 'which grep', will output the full path to the grep binary, such as '/usr/bin/grep', directly answering the user's request.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
man grep
Why it's wrong here
man grep displays the manual page describing grep's usage, options and syntax; it does not report the executable's filesystem path. It tempts because both concern locating information about a command, but path resolution requires which or type, which search PATH and return the binary's location.
- ✓
which grep
Why this is correct
The which command searches the directories listed in the PATH environment variable and returns the full path of the first matching executable. This directly locates the grep binary's filesystem location, satisfying the user's requirement without invoking or executing it.
- ✗
uname -a
Why it's wrong here
Uname -a prints kernel name, release and architecture details; it reports nothing about file locations. It is tempting because it is a common system-information command, but locating a binary requires searching the filesystem or PATH, which uname does not do.
- ✗
grep -r 'grep' /usr/bin
Why it's wrong here
This searches the contents of files under /usr/bin for the string 'grep' rather than resolving the executable's path, and the -r flag expects a directory argument. It is tempting because grep is a familiar text-search tool, and would be correct for locating which scripts reference a term.
Go deeper
Related to this question
About these practice questions
This LFCS question is part of Courseiva's 406-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.