Hasty Briefsbeta

Bilingual

Path Isn't Real on Linux

a year ago
  • #PATH
  • #Shell
  • #Linux
  • On Linux, the shell (like dash in Debian) is responsible for searching for executables in the PATH, not the kernel.
  • Commands like `cat` are resolved by the shell before execution, using the PATH environment variable to locate the executable.
  • Tools like Python's `subprocess.run`, Go's `LookPath`, and Rust's `Command::spawn` also handle PATH resolution in user space before calling system functions.
  • Linux's `execve` system call requires an absolute path, which is why shebangs must specify full paths or use `/usr/bin/env` to leverage PATH searching.