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.
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)- A3% (1)
- B84% (27)
- D9% (3)
- E3% (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.
cat PATH attempts to read a file named PATH in the current directory, not the environment variable, and no such file typically exists.
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.
The %PATH% syntax is specific to Windows Command Prompt; in Linux shells, % is not used to reference environment variables.
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.
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
Community Discussion
No community discussion yet for this question.