nerdexam
CompTIA

LX0-103 · Question #35

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 searches only the directories listed in the shell's PATH variable to locate an executable by name.

GNU and Unix 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

(59 responses)
  • A
    2% (1)
  • B
    93% (55)
  • C
    2% (1)
  • E
    3% (2)

Why each option

The 'which' command searches only the directories listed in the shell's PATH variable to locate an executable by name.

Alocate

'locate' searches a prebuilt file index database covering the entire filesystem and is not restricted to or aware of the PATH variable.

BwhichCorrect

The 'which' command iterates through each directory in the PATH environment variable and returns the full path of the first matching executable it finds. It is specifically designed for this purpose - finding command locations within the user's execution path, not the broader filesystem.

Cfind

'find' traverses a filesystem tree from a given starting point using specified criteria; it does not reference PATH unless explicitly scripted to do so.

Dquery

'query' is not a standard Linux/Unix shell command for locating files.

Ewhereis

'whereis' searches predefined standard directories (such as /bin, /usr/bin) for binaries, man pages, and source files - it does not dynamically use the user's current PATH variable.

Concept tested: Locating executables using PATH with 'which'

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

Topics

#which command#PATH variable#executable search#command location

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice