The PATH Variable Explained — Add a Tools Folder on Linux

What PATH is, why the shell searches it in order, and the safe way to prepend your own bin directory so personal scripts run from anywhere.

LinuxshellenvironmentpathcliLow risk
Run export PATH="$HOME/.local/bin:$PATH" (and add it to ~/.bashrc to keep it) so executables in your own bin folder are found without typing the full path.

01Command

Command
$ echo $PATH && export PATH="$HOME/.local/bin:$PATH"

02What it does

PATH is a colon-separated list of directories the shell searches, left to right, whenever you type a command name; the first match wins, which is why 'command not found' simply means no listed directory contains that name. Prepending your own directory ($HOME/.local/bin:$PATH) makes your scripts take precedence over system tools, while appending (:...$PATH) gives them the lowest priority — a crucial distinction when shadowing commands like python. Put the export in ~/.bashrc (or ~/.zshrc) so every new terminal inherits it, and confirm the result with echo $PATH and command -v yourscript.

03Risk

RiskLow risk
!Warning: Never put '.' or an empty entry in PATH: the shell would then run programs from whatever directory you're standing in, which is how attackers plant fake 'ls' binaries in shared folders.

04Undo

Undo
$ Remove the export PATH line from ~/.bashrc / ~/.zshrc and reopen the terminal

05Sources

  • which(1) — Linux manual page
    man7.org · community · 2026-09-17
    Evidence: which resolves command names against PATH, demonstrating the directory search order the shell uses.
  • bash(1) — Linux manual page
    Arch Linux · community · 2026-09-17
    Evidence: Documents PATH: a colon-separated list of directories searched in order for command execution; empty entries mean the current directory.

Last verified: 2026-09-18 · Category: Developer