CompTIA
LX0-103 · Question #35
LX0-103 Question #35: Real Exam Question with Answer & Explanation
The correct answer is B: which. The 'which' command searches only the directories listed in the shell's PATH variable to locate an executable by name.
GNU and Unix Commands
Question
An administrator is looking for an executable file foo. Which of the following commands would search for foo within directories set in the shell variable, PATH?
Options
- Alocate
- Bwhich
- Cfind
- Dquery
- Ewhereis
Explanation
The 'which' command searches only the directories listed in the shell's PATH variable to locate an executable by name.
Common mistakes.
- A. 'locate' searches a prebuilt file index database covering the entire filesystem and is not restricted to or aware of the PATH variable.
- C. 'find' traverses a filesystem tree from a given starting point using specified criteria; it does not reference PATH unless explicitly scripted to do so.
- D. 'query' is not a standard Linux/Unix shell command for locating files.
- E. 'whereis' searches predefined standard directories (such as /bin, /usr/bin) for binaries, man pages, and source files - it does not dynamically use the user's current PATH variable.
Concept tested. Locating executables using PATH with 'which'
Reference. https://man7.org/linux/man-pages/man1/which.1.html
Topics
#which command#PATH variable#executable search#command location
Community Discussion
No community discussion yet for this question.