Path Isn't Real on Linux

Misunderstanding PATH and the Kernel

  • Central theme: the article’s “PATH isn’t real on Linux” comes from discovering that PATH is handled in userspace, not by the kernel.
  • Many commenters find it unsurprising that the kernel doesn’t consult PATH; others note this isn’t obvious if you don’t already know the shell/kernel/libc split.
  • Several people point out the man-page section numbers (2 = syscalls, 3 = libc) but others argue most users don’t read manpages or know this convention.

Shell vs libc vs Kernel Responsibilities

  • PATH lookup, globbing, pipes, redirection, job control, and shell variables are all implemented by the shell.
  • The kernel’s execve/execveat syscalls just take a pathname and argv/envp arrays; they don’t parse environment variables at all.
  • Some exec* and posix_spawn* functions in libc do search PATH if no slash is present, reinforcing confusion about where PATH logic lives.
  • There’s discussion of the clear formal boundary at the syscall layer vs the “blurry” practical boundary introduced by libc wrappers and vDSO.

Alternative OS Designs and “Contingent” Behavior

  • Commenters stress that “PATH is userspace” is an implementation detail, not a universal law; kernels could do PATH searches.
  • Examples are given from Windows, QNX, AmigaOS, and macOS to show different splits between kernel and userspace (argument parsing, spawn vs exec, window handles, program loading).
  • Similar point: users, groups, and environment variables are just IDs/strings to the Linux kernel; mappings and semantics are in userspace.

Shebang Lines and PATH in Scripts

  • The kernel parses shebangs and can even be built without that feature.
  • #!/usr/bin/env ... is needed because the kernel doesn’t know PATH; #!sh may unexpectedly run a local ./sh.

PATH Caching and Shell Tools

  • Bash caches command lookups (hash builtin); stale cache entries can cause “command not found” despite PATH containing the binary.
  • hash -r (or rehash in zsh) clears this cache; command -v is recommended as a portable way to test for a command on PATH.

Meta: Title, Rudeness, and Learning

  • Some see the title as clickbait or misleading, since PATH is very much “real” as an environment variable.
  • There’s tension between “everyone should know OS fundamentals” and empathy for people learning these details later.