Terminal error: zsh: permission denied: ./startup.sh

I am running a command ./startup.sh nginx:start and I am getting this error message zsh: permission denied: ./startup.sh why could this be happening?


Solution 1:

Be sure to give it the execution permission.

cd ~/the/script/folder

chmod +x ./startup.sh

This will give exec permission to user, group and other, so beware of possible security issues. To restrict permission to a single access class, you can use:

chmod u+x ./startup.sh

This will grant exec permission only to user

For reference

Solution 2:

Alternatively you can use bash:

bash startup.sh

Then you don't need execution permission.

In MacOS Catalina, Apple has replaced bash with zsh as default shell. This can mean, that they intend to remove bash in the future, so this might not be an option later, but with Catalina it still works.

Solution 3:

Starting with macOS Catalina, Your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.

How to change your default shell Whether your user account is configured to use zsh (recommended), bash, or another shell, you can change the default shell from Users & Groups preferences or the command line.

  1. From Users & Groups preferences
  2. Choose Apple menu  > System Preferences, then click Users & Groups.
  3. Click the lock , then enter your account name and password.
  4. Control-click your user name in the list of users on the left, then choose Advanced Options.
  5. Choose a shell from the ”Login shell” menu, then click OK to save the changes.

Follow link for more details - https://support.apple.com/en-in/HT208050