LOGBOOK

HELP

Quiz Entry - updated: 2026.10.13

What does the line #!/bin/bash at the top of a script do, and why does the script still not run after it was created?

The shebang tells the kernel which interpreter runs the file; a new file has no execute bit, so chmod +x (for example sudo chmod 755 /usr/local/bin/myapp) is also needed.

When a file is executed and starts with #!, the kernel runs the program named after it and passes the file to it. So ./myapp with #!/bin/bash becomes /bin/bash ./myapp. Without the shebang, the file would be run by whatever shell started it, which may not be bash.

A file created with an editor gets rw-r--r-- (644) from the default umask, with no x anywhere. ls -la shows this. The kernel only executes files with the execute bit, so the fix is:

sudo chmod 755 /usr/local/bin/myapp    # rwxr-xr-x

755 (or chmod +x) lets every user, including the service account, run it. Only root can change it, because the file is owned by root.

Go deeper:

From Quiz: ISLAB / Access Management on Linux | Updated: Oct 13, 2026