nerdexam
CompTIA

LX0-103 · Question #57

Which of the following commands can be used to search for the executable file foo when it has been placed in a directory not included in $PATH?

The correct answer is C. find. The find command can search the entire filesystem for a file regardless of whether its directory is in $PATH, making it the correct tool when a binary is stored in a non-standard location.

GNU and Unix Commands

Question

Which of the following commands can be used to search for the executable file foo when it has been placed in a directory not included in $PATH?

Options

  • Aapropos
  • Bwhich
  • Cfind
  • Dquery
  • Ewhereis

How the community answered

(23 responses)
  • A
    4% (1)
  • C
    96% (22)

Why each option

The find command can search the entire filesystem for a file regardless of whether its directory is in $PATH, making it the correct tool when a binary is stored in a non-standard location.

Aapropos

apropos searches manual page descriptions for keywords and is used to discover commands by function, not to locate file paths.

Bwhich

which only searches directories listed in the $PATH environment variable and will not find executables placed outside those directories.

CfindCorrect

The find command traverses directory trees based on specified paths and criteria (e.g., find / -name foo), allowing it to locate any file anywhere on the filesystem independent of the $PATH variable. Unlike tools designed only for binaries in known locations, find performs a general-purpose recursive search and will match any file type including executables placed in arbitrary directories.

Dquery

query is not a standard Linux command for locating files.

Ewhereis

whereis searches a predefined set of standard binary and man page directories and will not find executables placed in non-standard locations outside those paths.

Concept tested: Locating files outside $PATH with find

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

Topics

#find#PATH#executable search#file location

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice