How to Fix the ‘zsh: permission denied’ Mac Terminal Error
Reading Time: 2 minutesGetting the ‘zsh: permission denied’ error in Terminal when you’re trying to open a file with a command? Here’s what you can do to fix it.
Do you keep receiving a ‘zsh: permission denied’ error on your Mac’s Terminal? Several reasons—such as insufficient permissions and ownership issues—often cause that.
Below, we’ll discuss some of the things you can do to fix the ‘zsh: permission denied’ error on the macOS Terminal. So, let’s get started.
Double-Check the Command
It’s a good idea to begin by double-checking the command that causes the ‘zsh: permission denied’ Terminal output. An incorrect command, syntax, or typo in the file path or filename is a common reason for the error.
If you’re new to command-line interpreters, feel free to check our beginner’s guide to the Mac Terminal and commands cheat sheet for help.
Unlock the File or Folder
The ‘zsh: permission denied’ Terminal error can also appear when you attempt to interest with a locked file or folder in macOS. To unlock the file or folder, Control-click the item, select Get Info, and clear the box next to Locked.
Alternatively, you can use the following command to unlock an item via the Terminal itself:
chflags nouchg [file or folder path]
Add Execute Permissions
If the ‘zsh: permission denied’ error occurs while opening an SH (shell script) file in the macOS Terminal, it’s likely that it does not have ‘execute’ permissions.
To fix that, use either of the following commands to add ‘execute’ permissions to the file:
chmod +x [SH file path]chmod +755 [SH file path]
Modify User and Group Ownership
If the ‘zsh: permission denied’ error persists, modify the user and group ownership of the file or folder with the following Terminal command. Replace both instances of USER with your Mac account username.
chown -R $USER:$USER [file or folder path]
ZSH Permission Denied Error on Mac Fixed
The macOS Terminal’s ‘zsh: permission denied’ is not an unusual error to encounter. An incorrectly-run command is often the primary suspect, but keep the rest of the above pointers in mind, so you know what to do the next time you run into it.