Shebang & Running in Bash

From the Bash Scripting cheat sheet · Getting Started · verified Jul 2026

Shebang & Running

Create, permit, and run a script.

bash
# Quick Reference
#!/usr/bin/env bash
echo "Hello, World!"

# make it runnable, then run
chmod +x script.sh
./script.sh
💡 #!/usr/bin/env bash finds bash on PATH - more portable than a hardcoded /bin/bash.
⚡ A script needs the executable bit (chmod +x) to run as ./script.sh.
📌 Run without +x via "bash script.sh" - the interpreter is explicit there.
🟢 # starts a comment to end of line; the shebang is only special on line 1.
basicsshebang

Continue with Bash Scripting

Save the full cheat sheet or work through every related task.

Back to the full Bash Scripting cheat sheet