You wrote a script, ran it, and got Permission denied. The file needs the execute bit:
chmod +x deploy.sh
Run it with ./
Once executable, run it by path. The ./ is required for a script in the current directory, because . is not on your PATH (for good security reasons):
./deploy.shdeploy.sh alone gives command not found; ./deploy.sh runs it. To run from anywhere, move it onto your PATH (for example ~/.local/bin or /usr/local/bin).
The shebang decides how it runs
The execute bit only says "this may be run". The first line, the shebang, says with what:
#!/bin/bash
echo "hello from bash"Common shebangs: #!/bin/bash, #!/usr/bin/env python3, #!/bin/sh. Without a shebang, the file runs under your current shell, which may not be what you wrote it for. #!/usr/bin/env python3 is the portable form because it finds python3 on the PATH rather than assuming a fixed location.
chmod +x adds execute for everyone
Plain chmod +x sets the execute bit for owner, group, and other (it respects your umask, but in practice gives rwxr-xr-x). To make a script executable only by you:
chmod u+x private.sh # execute for the owner onlyThat is the tighter choice for anything sensitive; see Linux file permissions explained for the owner/group/other breakdown.
FAQ
See also
- Linux file permissions explained: what the execute bit means and the rwx model.
- How to chmod recursively: the capital-X trick for whole trees of scripts.
- Change a user's login shell (chsh): the shell that runs your scripts.
Sources
Authoritative references this article was fact-checked against.





