Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

PATH

Direct answer

PATH is the colon-separated list of directories the shell searches, in order, for a command name. The first match wins.

When to use this

Use it when "command not found" appears, or the wrong version of a program runs.

First 30 seconds

1. type -a <cmd> — found? Which one first?

2. Not found → where is it installed? (dpkg -L <pkg> / rpm -ql <pkg>)

3. Add the directory: export PATH=$PATH:/opt/tool/bin (persist in ~/.profile).

4. Wrong version → reorder PATH or use the full path.

5. In cron/systemd → set PATH explicitly or use full paths.

Operational verification

command name typed → shell checks aliases/functions/builtins → searches PATH left to right → first executable match runs

Evidence · next step

For Linux Fundamentals → PATH, continue with the first unproven Topic check: Capture effective PATH from the exact user, shell, service, cron or automation context. If that boundary is healthy, advance to the adjacent check: Resolve the command type and actual executable path, considering aliases/functions/builtins before filesystem search. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it when "command not found" appears, or the wrong version of a program runs.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

caller/session/service environment → PATH value/order → command-type resolution → first executable candidate → permissions/interpreter/architecture → process start → workload result

Healthy evidence: the caller's effective PATH, command type and selected executable are explicit, permissions/runtime permit launch, and the expected workload succeeds with that exact binary.

Step 2 Verification and output interpretation Verify boundary

Existing fast checks for this Topic. - Capture effective PATH from the exact user, shell, service, cron or automation context.

  • Resolve the command type and actual executable path, considering aliases/functions/builtins before filesystem search.
  • Check directory order, file execute permissions and architecture/interpreter requirements for the selected executable.
  • Retest with an absolute executable path, then verify refreshed lookup and workload behavior after correcting PATH.

Verification chain. caller/session/service environment → PATH value/order → command-type resolution → first executable candidate → permissions/interpreter/architecture → process start → workload result

Step 3 Commands Verify boundary
echo $PATH
command -v python3
type -a python3
Step 4 Failure modes and next checks Narrow the fault

Suspicious evidence: PATH from an interactive shell is assumed for services/automation, later directory matches hide an earlier wrong binary, or command-not-found is fixed by adding broad/untrusted directories without proving ownership.

Step 5 Common mistakes Narrow the fault
  • Putting . in PATH.
  • Different PATH in cron.
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points

Root and services often have a shorter PATH than your user; cron's default is just /usr/bin:/bin. Use full paths in scripts and cron. After installing a program, run hash -r so Bash forgets the old location.

Key checks
  • echo $PATH — search order
  • type -a <cmd> — every match on PATH, in order
  • which <cmd> — first match
  • hash -r — clear Bash's remembered command paths
ReferenceWhat it is1 section · depth on demand

Core model

Capture PATH in the exact failing process/session, identify whether the invocation is a builtin/function/alias or external name, walk directories in order, verify the selected executable and permissions, and account for shell command hashing/caching where applicable. Absolute paths bypass PATH and are useful for isolating resolution from program behavior.

ReferenceImportant terms & boundaries5 sections · depth on demand

What this shows and what it does not

Successful name resolution shows only which executable was selected, but it does not show the binary can start, its dependencies resolve, or its operation succeeds.

In depth

PATH: how the shell finds commands

When a command name contains no slash, the shell searches for it. The bash(1) manual page describes the order:

1. Functions are tried first.

2. Then shell builtins.

3. Then each directory in PATH, from left to right. The first executable file with that name wins.

Bash remembers where it found each command in a hash table, so it doesn't search again every time. hash -r clears it. An empty element in PATH (a leading or trailing colon, or ::) means the current directory.

Typical PATH and priorities

DirectoryContents
~/.local/binThe user's own tools (when added)
/usr/local/sbin, /usr/local/binLocally installed software, outside the package manager
/usr/sbin, /usr/binDistribution packages
/sbin, /binOften symlinks to /usr on modern distributions

Diagnosing which command runs

CommandShows
type -a nameEvery match: aliases, functions, builtins, files in PATH order
command -v nameWhat would run (suitable for scripts)
hash / hash -rCached locations / clear the cache
echo "$PATH" | tr ':' '\n'The search order, one directory per line

Changing PATH safely

GoalMethod
Add a directory for one userexport PATH="$HOME/.local/bin:$PATH" in ~/.profile
System-wide for login shellsA file in /etc/profile.d/
For a systemd serviceEnvironment=PATH=... in the unit
For a scriptSet PATH at the top of the script
In a crontabPATH=/usr/local/bin:/usr/bin:/bin as the first line

Security

Never put ., or an empty element, in PATH, and never put a directory other users can write to ahead of system directories. Otherwise a file named like a common command (ls, sudo) in that directory runs instead of the real one. sudo uses its own secure_path for the same reason.

host$ echo "$PATH" | tr ':' '\n'
/home/admin/.local/bin
/usr/local/bin
/usr/bin
/bin
host$ type -a python3
python3 is /home/admin/.local/bin/python3
python3 is /usr/bin/python3
host$ ls -l /home/admin/.local/bin/python3
lrwxrwxrwx 1 admin admin 38 Nov 20 10:12 /home/admin/.local/bin/python3 -> /opt/pyenv/versions/3.13.0/bin/python3
host$ mv ~/.local/bin/python3 ~/.local/bin/python3.13
host$ type python3
python3 is hashed (/home/admin/.local/bin/python3)
host$ hash -r; type python3
python3 is /usr/bin/python3

Reading the example

A symlink in ~/.local/bin shadowed the system Python, because that directory comes first in PATH. After the file is renamed, bash still points to the old path from its hash table, until hash -r clears it.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

PATH is part of Linux Fundamentals → PATH. PATH is an ordered colon-separated list of directories consulted by shells and process-launch mechanisms for unqualified executable names; the effective result depends on the caller's environment, shell/runtime lookup rules, executable permissions and possible command caches.

Topic-specific state model. PATH is an ordered colon-separated list of directories consulted by shells and process-launch mechanisms for unqualified executable names; the effective result depends on the caller's environment, shell/runtime lookup rules, executable permissions and possible command caches.

Technical metadata. Distribution ID/release/family, CPU architecture, running kernel release, process/PID/UID/GID/session/namespace, parent/launcher/PID 1, shell implementation and invocation mode, terminal/TTY/PTY state, effective environment and variable provenance, PATH order, command type/resolved executable, package/artifact version, loaded configuration/runtime state, syscall/IPC/dependency boundary, exit/error evidence and workload-visible result.

Interpretation rule. - Directory appears in PATH ≠ intended executable is the first matching executable.

  • Executable file exists ≠ caller can execute it.
  • PATH fixed in one shell ≠ service, sudo, cron or automation uses the same PATH.
  • Changing PATH ≠ shell/runtime command cache is necessarily refreshed.

Quick reference

PATH is the ordered list of directories searched for commands.

echo $PATH | tr ':' '\n'
type -a python3; command -v ansible
hash -r                           # forget cached command locations
export PATH="$HOME/.local/bin:$PATH"

Security: never put . (current directory) or world-writable directories early in root's PATH. sudo uses secure_path from sudoers, and cron uses a minimal PATH (/usr/bin:/bin) — use full paths in crontab entries and systemd units.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Limits and how it fails

Primary failure point. Successful name resolution shows only which executable was selected, but it does not show the binary can start, its dependencies resolve, or its operation succeeds.

ReferenceConfiguration & state1 section · depth on demand

Configuration, persistence and lifecycle

Changes to a login profile do not retroactively alter existing processes; a PATH edit does not change already-resolved executable paths; a package update does not imply the running kernel changed until a reboot selects it.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

Authoritative/upstream documentation reviewed for bounded claims in Linux Fundamentals → PATH. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://docs.kernel.org/ · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
linux path variablecommand not found pathexecutable lookup linux
Embedded reference data

Quick lookup tables

PATH operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for PATH.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective statePATH is an ordered colon-separated list of directories consulted by shells and process-launch mechanisms for unqualified executable names; the effective result depends on the caller's environment, shell/runtime lookup rules, executable permissions and possible command caches.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin distribution/release + CPU architecture + running kernel → identify the exact process/session and kernel-versus-user-space boundary → capture shell/TTY mode and effective environment where relevant → resolve the real executable/consumer → correlate requested action with observed runtime state → verify the original workload result before changing persistent configuration.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chaincaller/session/service environment → PATH value/order → command-type resolution → first executable candidate → permissions/interpreter/architecture → process start → workload resultTrace requested/configured state through effective state to the observed workload result.
Failure boundarySuccessful name resolution proves only which executable was selected; it does not prove the binary can start, its dependencies resolve, or its operation succeeds.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated host, process/session and runtime evidence can establish this Linux Fundamentals proof path: caller/session/service environment → PATH value/order → command-type resolution → first executable candidate → permissions/interpreter/architecture → process start → workload resultUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove behavior outside the captured host, kernel, process/session, environment or workload scope. Successful name resolution proves only which executable was selected; it does not prove the binary can start, its dependencies resolve, or its operation succeeds.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven Linux layer: preserve platform identity and the running kernel, inspect the exact process/session and effective configuration/environment, resolve the actual consumer/executable, then verify the original workload before moving into the owning Linux subsystem branch.Continue to the next unresolved boundary while preserving the original test condition.

PATH · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundaryPATH
Topic pathLinux Fundamentals → PATH
Runtime statePATH is an ordered colon-separated list of directories consulted by shells and process-launch mechanisms for unqualified executable names; the effective result depends on the caller's environment, shell/runtime lookup rules, executable permissions and possible command caches.
Fast checks- Capture effective PATH from the exact user, shell, service, cron or automation context. - Resolve the command type and actual executable path, considering aliases/functions/builtins before filesystem search. - Check directory order, file execute permissions and architecture/interpreter requirements for the selected executable. - Retest with an absolute executable path, then verify refreshed lookup and workload behavior after correcting PATH.
Verification chaincaller/session/service environment → PATH value/order → command-type resolution → first executable candidate → permissions/interpreter/architecture → process start → workload result Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary.
Failure boundarySuccessful name resolution proves only which executable was selected; it does not prove the binary can start, its dependencies resolve, or its operation succeeds. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?