PATH in Linux: where commands are found
Updated July 3, 2026
PATH is a colon-separated list of directories where the shell looks for a command by its name.
Common cases
echo "$PATH" # the current list of directories
which ls # which directory the command came from
export PATH="$HOME/bin:$PATH" # add your own directory to the front
hash -r # clear the cached command pathsHow it works: search order is everything
When a command is not a builtin or alias, the shell walks the
PATHdirectories left to right and runs the first matching file it finds. So order matters: a directory near the front shadows same-named programs further along. You add your own directory like this:PATH="$HOME/bin:$PATH", keeping the old$PATHat the end, or the system losesls,catand everything else. Never put.at the front ofPATH: it lets a stray file run in place of the real command.
Used in
You need this in the lesson The shell environment. The theory is the chapter The shell environment and configuration.
See also
Environment variables, which, type, whereis, The ~/.bashrc file.
Try it
Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.