010-160 · Question #86
What is the purpose of the PATH environment variable?
The correct answer is A. It allows the execution of commands without the need to know the location of the executable. The PATH variable holds a colon-separated list of directories the shell searches when resolving command names, enabling commands to run without specifying their full path.
Question
Options
- AIt allows the execution of commands without the need to know the location of the executable.
- BIt increases security by preventing commands from running in certain locations.
- CIt specifies the location of a user's home directory.
- DIt indicates the location of the default shell to be used when a user logs in.
- EIt contains the absolute path to the current directory.
How the community answered
(22 responses)- A91% (20)
- C5% (1)
- D5% (1)
Why each option
The PATH variable holds a colon-separated list of directories the shell searches when resolving command names, enabling commands to run without specifying their full path.
When a user types a command, the shell iterates through each directory listed in PATH in order, looking for a matching executable file. This mechanism allows users to run programs like ls or grep by name alone rather than typing full paths like /bin/ls.
PATH does not restrict or block command execution in any directory - it is a lookup list, not an access control mechanism.
The home directory is specified by the HOME environment variable, not PATH.
The default login shell is specified by the SHELL environment variable and configured in /etc/passwd, not PATH.
The current working directory is stored in the PWD environment variable, not PATH.
Concept tested: Linux PATH environment variable purpose
Source: https://www.gnu.org/software/bash/manual/bash.html#Command-Search-and-Execution
Topics
Community Discussion
No community discussion yet for this question.