Summary: This post serves as a short and easy guide on the reasons why you are getting Zsh permission denied error that happens to appear in macOS Terminal and ways to fix it, as well as prevent the error from happening in the first place.
So, you are opening a file, and you have decided to do it with the help of the Terminal app. A moment later you see the Zsh permission denied error. How to fix that? Let us first take a look at the root of the problem itself.
The Zsh or the so-called Z shell is a Unix shell. It’s a macOS default shell designed on top of bash. In other words: it’s the default Shell in macOS (and a shell itself is the interface that provides access to an operating system’s services). Zsh is used more often than Bash (“bourne again shell”) since it is more powerful, and has an extended number of features.
The problem you are encountering appears when the Terminal cannot complete the task as it simply can’t access the file. Either the file is locked, the command has been formatted in a wrong way, or even the file permission is insufficient.
Since we have talked about file permissions, let’s start with them.
To check disk permissions through Terminal:
1. Open Terminal and paste the following command: ls -l. Add a space after the command and do not press Enter for now.
2. Find the file you need to open > drag it into the Terminal window (this will not actually move the item, but will do the trick).
3. Press Return.
If the letters “rwxr” appear before your username in the result string, it means you have the access to read, write, and execute the file. If there is only one sign, for example, “r”, it means the file is read-only to you.
If you are checking disk permissions of the file through Finder:
The permissions should now be visible to you. To have the necessary access, it should state “Read & Write”.
Let’s try changing the ownership of the directory:
Open Terminal again and use the command chown -R $USER:$USER /path/to/directory.
Where $USER is the currently logged-in user and /path/to/directory – a place you are writing it to.
If it is the case with Terminal, this might be another reason for the Zsh permission denied error.
To check if that’s true, and give them access to the disk, do the following:
Note: If Terminal is not on the list (this may happen in the newest macOS versions), you’ll need to add it manually by clicking the + button and searching Terminal in the search bar. Next, you’ll need to quit Terminal to apply the changes.
If none of the above helped use the superpower — a Sudo command. In simple words, a Sudo command stands for superuser do, when a permitted user gains super user privileges or executes a command as another user. Mind it will ask for the current (not the root one) user’s password when using the mentioned command for the first time.
Here are the commands you might try:
Yes, there are actually four of them. Read on to find out more.
Give permissions to a number of users and groups to prevent issues with permission. To do this:
Here’s what each permission means:
Giving permissions to all items on a disk or in a certain folder means they will be accessed only by certain users:
Issues with Zsh permission denied in Mac Terminal may also occur if the owner of an item is another user.
To change the owner of a file:
Adding or removing a user or group can also resolve permission issues.
Here’s how to do so:
If you happen to decide to open a file not by double-clicking it, but by doing it with Terminal instead — probably there is a reason why you have decided to use the less conventional way. Issues with accessing items this way are not uncommon, and we hope our simple guidelines will help you fix the error in no time, and with little effort. Since it is basically a permission issue, the first thing you would need to do is to check all possible permissions or check if the user you are logged under has sufficient access.
Ruslana is a tech content writer whose true passion is finding out about everything Mac-related. She specializes in creating macOS guides and tips & tricks. In her spare time, you’ll find her doing yoga or discovering local coffee shops in search of the best filter coffee.
Stellar Data Recovery has the right Windows Recovery tool for all your data recoveryRead More
Stellar Data Recovery for Mac program performs safe..
A comprehensive photo recovery software to restore photos, music & video files
Powerful video repair tool for repairing corrupt or damaged MOV and other video files