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

MacosNginxTerminalSh

Macos Problem Overview


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?

Macos Solutions


Solution 1 - Macos

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 - Macos

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 - Macos

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

Solution 4 - Macos

add sudo before command start, will save your time like

sudo anyTemninalCommand

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionReactingView Question on Stackoverflow
Solution 1 - MacosAndrea GolinView Answer on Stackoverflow
Solution 2 - MacosGefilte FishView Answer on Stackoverflow
Solution 3 - MacosSuraj PawarView Answer on Stackoverflow
Solution 4 - MacosJagveer SinghView Answer on Stackoverflow