PATH
An environment variable holding a list of folders the shell searches, in order, to find the program for a command you type.
In more detail
The first folder containing a match wins, so order decides which version of a program runs when several are installed. On Linux and macOS the entries are separated by colons, and on Windows by semicolons. The current directory is normally not on PATH on Linux and macOS, which is why you run a local script as ./script.sh.
Examples
echo "$PATH"echo $PATHIn Terraform: If the folder holding the terraform binary is not on your PATH, typing terraform gives a command not found error. That means the install is incomplete, not that anything is broken. Package managers and version managers add the right folder for you.Related terms
- environment variable — A named setting such as PORT=8000 that a program reads from its surroundings when it starts.
- type builtin — A bash builtin that tells you what a name would run: an alias, a keyword, a function, a builtin or a file on disk.
- env — A command that prints the environment, or runs another program with a changed environment or found through PATH.
- cron — The Unix and Linux service that runs commands automatically on a schedule, such as every night at two in the morning.
- shell — The program that reads the commands you type, runs them and shows the results; sh and bash are common ones.
- GOPATH — The Go setting that names a folder, by default go in your home folder, where downloaded modules are cached and installed tools are placed.
- which command — A shell command that shows which program a command name will run, by searching PATH the same way the shell does.
- Add python.exe to PATH — The checkbox at the bottom of the first Windows installer screen that makes python and pip work from any terminal.
- module search path — The list of folders Python searches, in order, when a program imports a module.
- binary — A compiled program file that a computer runs directly, as opposed to the source code it was built from.
- terminal — The text window where you type commands and read their output.
Taught in
- Which Shell Am I In, And Getting Bash Five — Bash Scripting & Command Line Automation
- Shebangs, Permissions And Three Ways To Run — Bash Scripting & Command Line Automation
- Scheduling, Monitoring And A Script That Reports — Bash Scripting & Command Line Automation
- Installing the Go Toolchain — Concurrent Systems Programming with Go
- Your First Program and go run — Concurrent Systems Programming with Go
- Installing Python On Windows — Hands-on Python: Complete Video Course & Book
- Installing Python On A Mac — Hands-on Python: Complete Video Course & Book
- Where Python Lives: PATH And Versions — Hands-on Python: Complete Video Course & Book
- First Run, And Fixing A Broken Install — Hands-on Python: Complete Video Course & Book
- Logins, su, sudo And SSH Between Hosts — Red Hat Certified System Administrator (EX200) Exam Prep
- Privileged Access: sudo Rules In Drop-In Files — Red Hat Certified System Administrator (EX200) Exam Prep
- Diagnosing Permission Problems — Red Hat Certified System Administrator (EX200) Exam Prep
- Exam-Style Scripts: Arguments, Output And Exit Codes — Red Hat Certified System Administrator (EX200) Exam Prep
- Repositories You Configure By File — Red Hat Certified System Administrator (EX200) Exam Prep
- Mount By UUID Or Label, For Good — Red Hat Certified System Administrator (EX200) Exam Prep
- Swap And New Volumes Without Losing Data — Red Hat Certified System Administrator (EX200) Exam Prep
- NFS Client Mounts That Survive The Boot — Red Hat Certified System Administrator (EX200) Exam Prep
- Installing Terraform And Meeting The CLI — Infrastructure as Code with Terraform
- Three Audit Findings And A Phone: Password Policy, Lockouts And MFA — CompTIA Linux+ (XK0-006) Exam Prep
- You Are In Emergency Mode: Boot Failures From GRUB To fstab, On Both Families — CompTIA Linux+ (XK0-006) Exam Prep
- Shared Libraries: Why A Program Will Not Start — LPIC-1 Linux Administrator (101-500 and 102-500) Exam Prep
- Anatomy Of A Playbook: Plays, Tasks And Modules — RHCE in Ansible (EX294): Automate Red Hat Systems
References
- Bash Reference Manual: Command Search and Execution
- Bash Reference Manual: Bourne Shell Variables (PATH)
- POSIX: environment variables (PATH)
- Using Python on Windows: environment variables
- Python on Unix: environment