Usually, you get the error bash permission denied when running some script/file that does not have execute permissions. All you need to do is to change file permissions and add executive one.
To fix the bash permission denied error follow this steps:
1. Open terminal (shell)
2. Navigate to the folder with the script
3. Run the CLI command to change file permission settings:
chmod +x path_to_file/file_name
For example, if you run a Magento 2 CLI command:
and get the error:
bash: bin/magento: Permission denied
You need to add an execute (x) permission to the bin/magento file.
For this, please run the CLI command:
chmod +x bin/magento
In case of Magento 2 you can also use the next command to avoid the issue (php before bin/magento):
php bin/magento ...