I have no idea how much relevance this short but informative rundown of how PATH works in Linux has in the real world, but I found it incredibly interesting and enlightening.
The basic gist – and I might be wrong, there’s code involved and I’m not very smart – is that Linux itself needs absolute paths to binaries, while shells and programming languages do not. In other words, the Linux kernel does not know about PATH, and any lookup you’re doing comes from either the shell or the programming language you’re using.
In practice this doesn’t matter, but it’s still interesting to know.
Umm I don’t think any OS kernel will search for a file name for user space.
Well…
Windows NT kinda does. The kernel API (ntdll) for loading images has an optional “search path” as one of its parameters. We can see an alternate implementation in ReactOS here:
https://doxygen.reactos.org/d7/d55/ldrapi_8c.html#a8838a6bd5ee2987045215ee7129c3a2c
Windows also has a “System” environment variable concept, in addition to the user space ones. The APIs on top of this are supposed to handle the details (Win32 in many cases, but of course they also support(ed) OS/2, DOS, Unix/Xenix, Linux as native APIs).