nerdexam
LPI

010-100 · Question #65

Which command shows all of the directories that the shell searches for programs?

The correct answer is B. echo $PATH. The $PATH environment variable holds a colon-separated list of directories the shell searches for executables; echo prints its current value to stdout.

The Power of the Command Line

Question

Which command shows all of the directories that the shell searches for programs?

Options

  • Aless $PWD
  • Becho $PATH
  • Cmore $ALL_PATH
  • Dget $PATH
  • Ecat $PATH

How the community answered

(30 responses)
  • A
    17% (5)
  • B
    70% (21)
  • C
    3% (1)
  • D
    7% (2)
  • E
    3% (1)

Why each option

The $PATH environment variable holds a colon-separated list of directories the shell searches for executables; echo prints its current value to stdout.

Aless $PWD

$PWD holds the current working directory, not the executable search path, so less $PWD would attempt to page through a directory listing, not show search paths.

Becho $PATHCorrect

echo $PATH expands the PATH environment variable and prints its value, which is the ordered list of directories the shell searches when resolving command names. This is the standard, built-in mechanism for inspecting the executable search path on any POSIX-compatible shell.

Cmore $ALL_PATH

$ALL_PATH is not a standard shell environment variable and does not exist by default on any POSIX system.

Dget $PATH

get is not a standard shell built-in or common utility; no such command exists for printing environment variables.

Ecat $PATH

cat reads file contents by path; $PATH expands to a string of directory names, so cat $PATH would attempt to open a file whose name is that string, not print the variable's value.

Concept tested: Inspecting the shell executable search path variable

Source: https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Variables.html

Topics

#PATH variable#shell environment#echo command

Community Discussion

No community discussion yet for this question.

Full 010-100 Practice