$linuxjunkies
>

PATH

PATH is an environment variable that lists directories where the shell searches for executable programs when you type a command. It determines which version of a program runs when multiple copies exist on your system.

PATH is a colon-separated list of directory paths that the Linux shell consults whenever you enter a command. Instead of typing the full path to every program (like /usr/bin/ls), the shell automatically searches each directory in PATH and runs the first matching executable it finds.

For example, if your PATH is /usr/local/bin:/usr/bin:/bin and you type ls, the shell looks for an executable named ls in /usr/local/bin, then /usr/bin, then /bin—and executes the first one found.

You can view your current PATH with echo $PATH and modify it temporarily with export PATH=$PATH:/new/directory. Adding directories to PATH is common when installing custom software, but order matters: directories listed first take precedence, so malicious actors sometimes manipulate PATH to hijack commands.

Related terms