You got ‘Zsh: Permission Denied: / error message while trying to execute a command on your Terminal ? Were you trying to access a directory through Terminal ? Yes, it means you lack Permission to perform the task, But why ? Read on to find out what is Zsh on your Mac and also why & how to fix the Zsh permission denied in Mac terminal issue.
What is Zsh
Zsh or Z shell is a Unix shell on Mac which is a command line interpreter that helps execute various commands on Terminal. Since macOS Catalina, Zsh is the default shell built upon bash which was the default shell for earlier macOS versions.
The standing out feature for Zsh is it doesn’t require strict user permissions for some tasks unlike bash and also includes a wide range of configuration and customization options such as plugins and themes availability.
What is Zsh: permission denied in macOS Terminal
The Zsh Permission denied error in macOS Terminal appears when you try to access or modify a file or folder on your Mac through a command on Terminal which needs permission to execute the command.
There could be many reasons for the Zsh permission denied error to appear, however the error message states that the execution of the command was prevented due to lack of permissions.
Why are you getting the permission denied error in Terminal
The permission denied error on Terminal is mainly due to lack of access grant to modify or access the file or directory through a command from Terminal. We have listed out a few of the main reasons to get ‘Zsh Permission Denied error’ on your Mac.
1. Incorrect command inputs usually result in permission denied error in Terminal. Make sure the entered command is valid and correct to execute by Terminal.
2. Most common reason is due to lack of permission on the file you are executing a command. Check if the file has to be accessed by you to run the command from Terminal.
3. Sometimes the file or folder is locked by the owner or requires administrator privileges to access or modify it.
4. The directory you are trying to access or modify from Terminal might not have given the Terminal access.
4 Ways to fix Zsh permission denied error on Mac
1. Check file/folder permissions
After you finish checking the correct command and it is accurate then check if you have the permission to access the file or folder you are trying to execute the command on. Follow below steps to check permission:
a. Open a new Terminal window on your Mac from Finder > Applications > Utilities > Terminal path.
b. Enter the following command into the Terminal : ‘ ls -l ‘
c. Locate the file or folder you were trying to access and get zsh permission denied error and drag the same into the Terminal window now. Then finally press Return key.
d. It will return a string of characters in front of your username –
- ‘ rwxr ’ – it means you are allowed to read, write and execute the file.
- ‘ r ’ – it means you are only allowed to read. No permission to write or execute.
If you have ‘rwxr’ result then you can freely execute the command on the Terminal without any zsh permission denied error, otherwise you need to modify the permission to execute the command without any error.
2. Change file permissions
Once you know the permission status on the file or directory, you can modify the file permission following below steps.
1. Find the file you were trying to execute through Terminal on Finder.
2. Now Right-Click on the file and Select ‘Get Info’ option.
3. Click on the ‘lock icon’ at the bottom right to make changes.
4. Select the ‘Sharing & Permissions’ tab on top, find your user profile name.
5. Then, Go to the Privilege column and change it to Read & Write.
Now that you have altered the permission status of the file to Read & Write, you can try and execute the command that previously gave zsh permission denied error on your Mac.
3. Change directory ownership
You got Zsh permission denied on Mac issue still after modifying disk permissions then consider changing the directory ownership with chown command.
Open a new Terminal window on your Mac, and enter the following commands with $USER = Your username and ‘/path/to/directory’ to the location path you want to write it.
- chown -R $USER:$USER /path/to/directory
This will change the ownership of the directory you were trying to access and will resolve the zsh permission denied issue when you run the command again.
4. Provide Terminal full access to disk
Sometime it is possible that the Terminal doesn’ have full access to the disk, hence the Zsh permission denied on Mac. Below steps shows you how to provide full access to Terminal.
a. Select the Apple menu at the top right corner and Click on System Preferences. Then Click on the ‘Security & Privacy’ option from the list.
b. Now on the Security & Privacy window, Select ‘Privacy’ tab at top and Click on the ‘lock icon’ button at the bottom and provide password when prompted to enable make changes.
c. Select the ‘Full Disk Access’ option from the left panel of the window.
d. Now Click on ‘+’ button to add Terminal option to the list from the utilities folder.
Now Terminal has full disk access to execute the commands you wanted to previously without any zsh permission denied issue.
Final Words –
The “ Zsh: Permission Denied: / “ error message appears only when you have no permission to access or modify the file you are trying to run the command in Terminal on your Mac. It can also be easily solved by following the easy solutions provided above, to grant permission to execute the command on Terminal without error. Try all the given solutions one after another to find out which one would fix it for you.