What is the purpose of the PATH variable?

Answer

PATH is a colon-separated list of directories that the shell searches when you type a command name without a full path. For example, if PATH=/usr/bin:/usr/local/bin:/bin, typing ls causes the shell to look for an executable named ls in each directory in order until it finds one. Add a directory: export PATH="$PATH:/new/dir". Permanently add it in ~/.bashrc or ~/.profile. The shell command which ls shows which PATH entry provides a given command. Security note: never put . (current directory) in PATH as it creates command injection risks.