LFCS · Question #870
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 be used to recursively search for files, including executables, in specified directories, irrespective of the $PATH environment variable.
Question
Options
- Aapropos
- Bwhich
- Cfind
- Dquery
- Ewhereis
How the community answered
(36 responses)- B3% (1)
- C89% (32)
- D3% (1)
- E6% (2)
Why each option
The `find` command can be used to recursively search for files, including executables, in specified directories, irrespective of the `$PATH` environment variable.
`apropos` searches the man page database for keywords, not the filesystem for executable files.
`which` specifically searches for executable commands only within the directories listed in the user's `$PATH` environment variable.
The `find` command is capable of recursively searching specified directories for files based on various criteria, such as name, type, and permissions, making it ideal for locating an executable file not present in the system's `$PATH`.
`query` is not a standard Linux command for searching for files on the filesystem.
`whereis` locates source, binary, and man page files for a command, primarily by searching standard system locations, not arbitrary directories outside `$PATH`.
Concept tested: File searching utilities
Source: https://man7.org/linux/man-pages/man1/find.1.html
Topics
Community Discussion
No community discussion yet for this question.