nerdexam
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. search is not a valid Linux command, so this syntax would produce a command not found error.
  • B. search is not a valid Linux command, and even if it were, no flag is used to specify a filename pattern.
  • C. -file is not a valid option for the find command; the correct option for matching by filename is -name.
  • E. While find /home foo.txt uses the correct command, it omits the required -name flag, 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.

Full 010-150 Practice