
# ./helloWorld.sh
bash: ./helloWorld.sh: Permission denied
If you are trying to run a Bash (.sh) script on your Terminal and you get a "Permission denied" error then most likely is that the script file does not have the execute permissions. You can check that by the ls command
# ls -l helloWorld.sh
-rw-r--r-- 1 root root 30 Apr 5 10:43 helloWorld.sh
Let's read the permissions out,
r = represents read permission.
w = represents write permission.
x = represents executable permission.
- => This is not a directory
r => owner has read permission
w => owner has write permission
- => owner does not have execute permission
r => group has read permission
- => group does not have write permission
- => group does not have execute permission
r => group has read permission
- => group does not have write permission
- => group does not have execute permission
As you can see we do not have the execute permission!
Fix: Add execute permission using chmod command# chmod +x helloWorld.sh
More Posts related to Bash,
- How to start or open a new bourne-again shell (bash) session on Windows using Command Line CMD
- How to create new user account in Windows bash
- Bash Hello World! Script Tutorial
- How to Compare Strings in Bash
- How to see Created Accessed Modified and Changed dates of a file using bash terminal command
- Command to Sort File In Reverse Order [Unix/Linux/macOS]
- Bash command to wait for seconds
- [fix] bash: ssh: command not found
- bash: netstat: command not found
- Know Bash shell version command
- List all Username and User ID using Bash Command
- How to use Autocomplete and Autosuggestion in Shell Commands
- How to know the current shell you are logged in?
- [Fix] bash: script.sh: /bin/bash^M: bad interpreter: No such file or directory
- 'pwd' is not recognized as an internal or external command, operable program or batch file. [Windows]
- How to Kill a port using bash terminal command?
- How to fix bash ping command not found error
- Install Bash Completion on macOS
- bash get year 2021 calendar
- How to check your IP using bash for Windows?
- Bash For Loop Example
- Fix bash: script.sh: Permission denied Error
More Posts:
- 9 Border to DIV Element in HTML Examples - Html
- Limit scrollback rows in macOS Terminal - MacOS
- Calculate Area and Circumference of Circle - C-Program
- Facebook Thanks for stopping by! We hope to see you again soon. - Facebook
- How to Refresh Mac Desktop - MacOS
- [Maven] Multiple annotations found at this line pom.xml CoreException, ArtifactResolutionException - Java
- Java SE JDBC with Prepared Statement Parameterized Select Example - Java
- Error: Can not find the tag library descriptor for - Java