LPI
010-150 · Question #14
010-150 Question #14: Real Exam Question with Answer & Explanation
The correct answer is D. find /home -name foo.txt. The Linux find command searches for files using specific flags; -name is the correct flag to match by filename.
Question
How could one search for the file foo.txt under the directory /home?
Options
- Asearch /home -file foo.txt
- Bsearch /home foo.txt
- Cfind /home -file foo.txt
- Dfind /home -name foo.txt
- Efind /home foo.txt
Explanation
The Linux find command searches for files using specific flags; -name is the correct flag to match by filename.
Common mistakes.
- A.
searchis not a valid Linux command, so this syntax would produce a command not found error. - B.
searchis not a valid Linux command, and even if it were, no flag is used to specify a filename pattern. - C.
-fileis not a valid option for thefindcommand; the correct option for matching by filename is-name. - E. While
find /home foo.txtuses the correct command, it omits the required-nameflag, making it invalid syntax that would produce an error.
Concept tested. Linux find command filename search option
Reference. https://man7.org/linux/man-pages/man1/find.1.html
Community Discussion
No community discussion yet for this question.