Zsh permission denied error occurs in the Zsh shell of the macOS terminal. This error message pops up when there’s an error in the file/folder/directory, macOS, or the command entered by you to open a particular file/directory. In addition, this error can also get displayed if you don’t have permission to access the file. However, there are many other more reasons which could lead to this error. In this article, we have described all the prominent causes and relevant solutions in detail. If you’re a regular macOS user & have been facing this error often, go through the listed solutions, implement any of them & see which one works out for you.
Major Reasons Which Cause Zsh Permission Denied Error
- Locked File: The root cause of this error could be that the file you’re trying to access or modify is locked by the owner. They must have used chmod command to lock that file due to which you’re unable to open it. In clear terms, you don’t have the administrative rights to open the file which is leading to the display of zsh permission denied error.
- Wrong Chmod Command: You’ll encounter this error if you enter the wrong chmod x or system command despite of having the owner rights. In such cases, verify the command and then enter it again. When opening a file or running an application, always make sure that you’re entering the right command to avoid such troublesome errors.
- Not Having Permissions: Lastly, if you lack the appropriate permissions to open a file or directory, then there are higher chances that you’ll face this error. It might happen if you’re not the owner or if permission to access the file is not granted by the respective owner.
- Incorrect File or Directory Name: Entering a wrong file name can also lead to this error. Make sure to check the entire file spelling thoroughly before entering it.
Also Read: How To Update Safari On Mac & Keep Your Browser Updated In 2023
5 Simple & Effective Solutions To Fix Zsh Permission Denied
Perform Permissions Check
You should check for disk permissions if you don’t have the authority to modify the file. To do so, follow the steps mentioned below:
- Step 1: To begin, you need to launch the Terminal via the Mac Utilies menu
- Step 2: Enter the command: ls-l
- Step 3: Add space next to the final command and do not hit the Enter button
- Step 4: Search for the file/folder you wish to open
- Step 5: Upon finding the file/folder, use Finder to choose the file and then drag it toward the terminal window
- Step 6: Tap on the Terminal Window and then hit Enter
Important: If all the letters resemble like string characters prior to your username then only you have the necessary rights to modify, read or write the specific file. If it shows “r” then you’re only allowed to read the file |
Change File Permission
If the permission denied problem persists when you try to open the file with owner permissions, then you need to make some modifications to the file permission. Follow the steps mentioned below to perform this method:
- Step 1: At first, you need to tap right on the file you need to work on
- Step 2: Click on the ‘Get Info’ option
- Step 3: Tap the arrow if you’re unable to access the details in the Sharing & Permissions
- Step 4: Select a User or Group from the ‘Name Column’
- Step 5: Lastly, from the pop-up menu displayed on the screen, choose the ‘Privilege Setting’ option. You’ve now successfully altered the permissions & can seamlessly work on the file
Make Use Of Sudo Command
The masterstroke technique to resolve permission denied error in the Mac Terminal is the Sudo command. It’s known as “substitute to do” or “super user do” & is a robust command which holds the power to run different types of commands smoothly & also provides superuser privilege to you. Enter the Sudo commands mentioned below and remember to use them prior the original command which you wish to run on the Terminal.
- sudo chmod 755 /dvtcolorconvert.rb
- sudo chmod 755 ~/Themes/ObsidianCode.xccolortheme
Note: If you’re first-time Sudo command user then do enter the password and then only you will be allowed to run the command. |
Opt For Directory Ownership Modification
If none of the above methods work out for you then we would suggest modifying the directory ownership using the chmod command to your username. To execute this method follow the steps mentioned below and do enter the right command for faster resolution.
- Step 1: Type this command: “chown -R $USER:$USER /path/to/directory”
- Step 2: Enter your original Mac username in place of $USER and the location in the path/to/directory space
- Step 3: Click on the Enter button
Also Read: Play 32 bit Games On Mac & Revive Old Days Again
Provide Terminal Control Fully To The Disk
Zsh permission denied error can also arise if the Terminal doesn’t have incomplete disk access. You need to give complete disk access to the Terminal and then only the error will get resolved. Additionally, having no disk access can also lead to another popular terminal error: “Operation not permitted” so to avoid such mishappenings, always give relevant disk access to the Terminal. Here’s how you should do it:
- Step 1: Open the System Settings by clicking the Apple logo displayed on the upper right screen area
- Step 2: Search for the Privacy & Security option from the System Settings menu & click on it
- Step 3: To proceed further, tap on the third last option denoted as Full Disk Access in the right panel
- Step 4: Go ahead and tap on the Terminal and give access. Make sure you give complete access
- Step 5 (Alternative): You can add the Terminal via manual method if unfortunately it’s not specified in your Mac
- Tap on the “+“ button
- In the search bar, write Terminal to add it to the Mac
- Drop out of the Terminal Window
- Open the Terminal to stimulate the changes
Conclusion
Occurence of zsh permission denied error is quite common when you try to open or access a file out of your rights. We know how irritating it gets and that’s the reason we have framed this piece of information. By now you must have clearly understood about the problems which lead to this issue and must have also garnered an understanding of how to resolve it following the solutions mentioned above. Do let us know in the comments section how much time did it take you to eliminate this problematic error.
Frequently Asked Questions (FAQs)
Q) What are the ways to avoid zsh permission denied on Mac Terminal?
Ans: This error can be easily avoided if you provide complete Access Privileges to different users & groups at one time. You can also alter the file owner or delete a user or a group to prevent this error.
Q) How can I confirm if zsh is installed in MacOS or not?
Ans: Zsh comes pre-installed in all the macOS ship versions. By using the command zsh—version you can get all the details about the Mac version you’re working on. If the macOS version is 4.3.9 or higher, then be rest assured as zsh is installed in all the versions which are about 4.3.9 or above it.