OA. free
Free
Accenture Core Computer Science Core Computer Science Medium

In a Linux bash shell, when you type a command and get command not found, which environment...

Accenture technical mcq question, verified with a worked answer. Free to practise - no sign-up.

In a Linux bash shell, when you type a command and get command not found, which environment variable determines the list of directories searched for the binary?

Choose one option.
Show answer & explanation
Answer: A. PATH

The PATH environment variable contains a colon-separated list of directories that the shell searches for executable binaries when you type a command. When a command is not found in any directory listed in PATH, the shell returns 'command not found'. HOME is the user's home directory, SHELL is the path to the current shell, and USER is the current username—none of these control command lookup.

Step-by-step Derivation:
When you execute a command in bash: 1) The shell checks if it's a built-in command (like 'cd', 'echo'). 2) If not, it searches for an executable file by looking through each directory listed in the PATH variable in order (e.g., /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin). 3) If found, it executes the binary; if not found in any PATH directory, it outputs 'command not found'. This is core shell behavior defined by the POSIX standard and implemented in all Linux shells.