Linux - Execute a script
When you execute a script in Linux (e.g., ./myscript.sh), the kernel handles it using a special binary format handler called binfmt_script.
The kernel opens myscript.sh and reads the first few bytes. It sees the #! (shebang) and realizes this is a script, not a compiled ELF binary.
It parses the interpreter path (e.g., /bin/bash).
The kernel then essentially replaces the execution request. Instead of executing the script directly, it executes the interpreter (/bin/bash) and passes the script's path as an argument.
Because of this, as far as the kernel's core process tracking is concerned, the process is running the interpreter, not the script.
If you look at /proc/[pid]/exe (which tracks the executable of a process), it will point to /bin/bash, and its inode will be the inode of /bin/bash.
The script itself (myscript.sh) is just a file that the interpreter opens to read the commands. The script's inode is simply the inode of that file on the filesystem. While the script is running, you will usually find the script's inode referenced as an open file descriptor (e.g., in /proc/[pid]/fd/255 or similar, depending on the interpreter).