Nono.MA

[Solved] /bin/sh Permission denied error Command failed with exit code 126

JULY 20, 2023

If you're trying to run a Bash script and get a Permission Denied error, it's probably because you don't have the rights to execute it.

Let's check that's true.

# Get the current file permissions.
stat -f %A script.sh
# 644

With 644, the user owner can read and write but not execute.1

Set the permissions to 755 to fix the issue.

chmod 755 script.sh

  1. Chmod 644. CHMOD Calculator. 

BlogCodeBashShError