Pcornel
Linux · Linux Fundamentals

PATH

Cheat sheet · https://pcornel.dk/topic.php?topic=2657

Back to the Topic

Answer

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

Remember

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.

First 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

Commands

sudo

Verify in this order

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

Where it usually breaks

First mismatch in persistent intent → provider/parser/generator → kernel/userspace runtime → dependency/security context → logs/counters → consumer-visible read-back; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2657

Confirmation

Confirm action

Continue?