Environment Variables

Environment variables store information. They're storage locations that are a name value pair, and all the letters in the variables are typically uppercase. You can see the content of the variable by using the echo $<VAR_NAME> command. The most widely used environment variable is $PATH, which contains a list of command search path.

$PATH variable

$PATH is an environment variable. It controls the command search path. It contains a list of directories that are separated by a colon. What I mean by that it controls the command search path is that, when you type in a command at the prompt and press Enter, that command will be searched in the directories that are listed in your path environment variable.

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

In above example, /usr/local/bin will be searched first. If the command is found there, it will be executed. If not found, then /usr/bin will be searched. This process goes on and on until either the command is found in your path or you will be told it can't be found if it doesn't match your request.

which command

If you want to know the location or the full path to the command that you are executing, use the which command.

For Example:
$ which cat
/bin/cat

If there are multiple programes named cat, then the one that gets executed depends on your search path. If cat is in /usr/local/bin and also in /usr/bin, which ever directory occurs first in your path will be the cat command that gets executed.