🐧 Linux / Shell Scripting
Beginner
What is the shebang line?
Answer
The shebang (or hashbang) is the first line of a script: #!/path/to/interpreter. The #! tells the OS kernel which program should execute the script. Common examples: #!/bin/bash for Bash scripts, #!/bin/sh for POSIX-compatible scripts, #!/usr/bin/env python3 for Python (using env to find the interpreter in PATH — more portable). Without a shebang, the kernel defaults to /bin/sh. The shebang is only meaningful when the script is executed directly (not when passed to an interpreter explicitly). Always include a shebang for clarity and portability.