nerdexam
LPI

010-150 · Question #14

How could one search for the file foo.txt under the directory /home?

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.

Initial Client Consultation and Assessment

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

How the community answered

(57 responses)
  • A
    5% (3)
  • B
    2% (1)
  • C
    7% (4)
  • D
    84% (48)
  • E
    2% (1)

Why each option

The Linux `find` command searches for files using specific flags; `-name` is the correct flag to match by filename.

Asearch /home -file foo.txt

`search` is not a valid Linux command, so this syntax would produce a command not found error.

Bsearch /home foo.txt

`search` is not a valid Linux command, and even if it were, no flag is used to specify a filename pattern.

Cfind /home -file foo.txt

`-file` is not a valid option for the `find` command; the correct option for matching by filename is `-name`.

Dfind /home -name foo.txtCorrect

The `find` command is the standard Linux utility for searching files and directories. The `-name` option specifies a filename pattern to match, making `find /home -name foo.txt` the correct syntax to locate foo.txt under /home recursively.

Efind /home foo.txt

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

Source: https://man7.org/linux/man-pages/man1/find.1.html

Topics

#find command#file search#name flag#directory search

Community Discussion

No community discussion yet for this question.

Full 010-150 Practice