nerdexam
LPI

010-100 · Question #73

Which command shows if /usr/bin is in the current shell search path?

The correct answer is B. echo $PATH. In Linux/Unix shells, environment variables are referenced with a $ prefix. The echo command prints the value of the $PATH variable, which lists directories the shell searches for executables.

The Power of the Command Line

Question

Which command shows if /usr/bin is in the current shell search path?

Options

  • Acat PATH
  • Becho $PATH
  • Cecho %PATH
  • Dcat $PATH
  • Eecho %PATH%

How the community answered

(32 responses)
  • A
    3% (1)
  • B
    84% (27)
  • D
    9% (3)
  • E
    3% (1)

Why each option

In Linux/Unix shells, environment variables are referenced with a $ prefix. The echo command prints the value of the $PATH variable, which lists directories the shell searches for executables.

Acat PATH

cat PATH attempts to read a file named PATH in the current directory, not the environment variable, and no such file typically exists.

Becho $PATHCorrect

The echo command outputs text or variable values to standard output, and $PATH is the correct shell syntax to dereference the PATH environment variable in Bash and other POSIX-compatible shells. Running 'echo $PATH' will print the colon-separated list of directories in the search path, allowing you to confirm whether /usr/bin is included.

Cecho %PATH

The %PATH% syntax is specific to Windows Command Prompt; in Linux shells, % is not used to reference environment variables.

Dcat $PATH

cat $PATH would attempt to use the value of $PATH as a filename to read, which would fail or produce garbage output since PATH contains directory paths separated by colons.

Eecho %PATH%

echo %PATH% uses Windows CMD syntax and is not valid in Linux shells; it would literally print the string '%PATH%' rather than the variable value.

Concept tested: Displaying PATH environment variable in Linux shell

Source: https://www.gnu.org/software/bash/manual/bash.html#index-PATH

Topics

#PATH variable#environment variables#echo command#shell

Community Discussion

No community discussion yet for this question.

Full 010-100 Practice