Linuxlab

The script file and how it runs

Updated July 3, 2026

A script is a text file of commands. To run it as a program you need two things: a shebang on the first line and the execute bit.

The shebang #!/usr/bin/env bash tells the kernel which interpreter to run the file with. env bash finds bash on the PATH, so the script is portable between systems.

chmod +x ~/count.sh   # add the execute bit
./count.sh            # run it as a program
bash ~/count.sh       # run it by calling bash explicitly

./count.sh only works with the x bit. bash count.sh always works: there you hand the file to the interpreter yourself, so the bit is not needed.

Used in

You need this in the lesson Bash: writing scripts.