nerdexam
Linux_Foundation

LFCS · Question #848

An administrator is looking for an executable file foo. Which of the following commands would search for foo within directories set in the shell variable, PATH?

The correct answer is B. which. The which command locates executable files in the directories specified by the shell's PATH environment variable.

Submitted by olafpl· Apr 18, 2026Essential Commands

Question

An administrator is looking for an executable file foo. Which of the following commands would search for foo within directories set in the shell variable, PATH?

Options

  • Alocate
  • Bwhich
  • Cfind
  • Dquery
  • Ewhereis

How the community answered

(68 responses)
  • A
    1% (1)
  • B
    93% (63)
  • D
    1% (1)
  • E
    4% (3)

Why each option

The `which` command locates executable files in the directories specified by the shell's `PATH` environment variable.

Alocate

`locate` searches a pre-built database of all files on the system, which may not be up-to-date and does not respect the `PATH` variable.

BwhichCorrect

B is correct because the `which` command specifically searches the directories listed in the user's `PATH` environment variable for the executable file specified as an argument. It then prints the full path to the first executable found, indicating which version of the command would be executed.

Cfind

`find` searches the filesystem based on specified criteria (path, name, permissions, etc.) but does not implicitly use the `PATH` environment variable.

Dquery

`query` is not a standard Linux command for searching executables in `PATH`.

Ewhereis

`whereis` locates source, binary, and man page files for a command, but it searches a predefined set of standard directories, not strictly the `PATH` variable.

Concept tested: Locating executables in PATH

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

Topics

#Executable files#PATH variable#Command line utilities#File location

Community Discussion

No community discussion yet for this question.

Full LFCS Practice