What is PATH
There are many technical definitions that can be found, but in simple terms, PATH is a list of directories.The listed directories will contain the software that run on the computer, including the command-line programs. PATH is a variable, and thus this list is flexible and new directories can be added.
When the user calls for a command such as listing all files (
ls) the command need to be located (found) and that is done simply by looking within each of the listed directories in the order they are listed. As soon as a matching command is found it can then be executed. Thus, the
ls command will be found within the
/bin directory and the command equivalent to
/bin/ls will execute.
The very first encounter to a matching command is the one used. If another copy or version exists elsewhere it is ignored.
Conceptually, we can think of that list to be in fact the compilation of all commands, scripts, executables, binaries, software etc. that are contained within the PATH listed directories.
An overlooked variable
If this variable is not defined, the computer will not know (find) any command! Therefore it is of the utmost importance. But sadly PATH is rarely explained or mentioned. Some software installer might change (add) directories to PATH automatically. In other case there will be a suggestion to modify PATH without much explanation, assuming that the user knows exactly what we are talking about.
PATH is on all systems
Web searches often direct to pages explaining variables in Linux, Unix, or macOS. But PATH is also used within Windows.
Here are a few links that I found useful:
- What the heck is my PATH, and how do I get it to do what I want? – [Archived]
- What Is the Unix PATH, and How Do You Add Programs To it? – [Archived]
- How to Set the PATH Variable in macOS – [Archived]
- How to Copy a File Path as Text from Mac Finder in Mac OS X – [Archived]
- How to set the path and environment variables in Windows – [Archived]