in

How to Fix Zsh Permission Denied in Mac Terminal in 2022

How to Fix Zsh Permission Denied in Mac Terminal

Receiving the Zsh Permission Denied error when making changes to a file using the Terminal? ? Learn How to Fix Zsh Permission Denied in Mac Terminal in this guide. 

The Terminal on Mac is an important and useful tool when it comes to accessing and making system-level changes on your Mac. It is similar to the command prompt on Windows. 

However, it is not an easy tool to use. Since you need to enter commands, you might make mistakes or not know what you are doing. One common error users face with Mac Terminal is the Zsh Permission Denied error. 

If you are someone who is facing this issue, then you are at the right place, check out How to Fix Zsh Permission Denied in Mac Terminal in this article.

To Fix Zsh Permission Denied in Mac Terminal, do the following,

  • Check Disk Permissions
  • Change Directory Ownership to Solve Zsh Permission Denied
  • Grant Terminal with Access to the Disk
  • Use Sudo Commands 

If you don’t know how to perform the above fixes, then continue reading our guide where we explain each fix in detail with steps. We also explain how to prevent the error in this How to Fix Zsh Permission Denied in Mac Terminal guide.

Related: How to Fix “HPDeviceMonitoring.framework” Will Damage Your Computer Error on Mac?

How to Fix Zsh Permission Denied in Mac Terminal

What is Zsh?

Zsh, also known as the Z shell is a Unix Shell on macOS. Shells are interfaces that provide access to an operating system’s services. Zsh is a default macOS shell that works on top of Bash (Bourne Again Shell). Zsh is used more than Bash since Zsh is more powerful and has more features.  

What is the Zsh Permission Denied Error?

How to Fix Zsh Permission Denied in Mac Terminal

Zsh Permission Denied error in Mac Terminal happens when the Terminal cannot access the file to complete. This can happen if the command is wrong, or if the file is locked. It can also happen if the file permission is not met. 

Ways to Fix the Zsh Permission Denied Error in Mac Terminal

Check Disk Permissions

Since file permissions are likely the cause for the Zsh Permission Denied error, let us check them first. 

See also  Fix Purple/Blue/Pink/Black/Green Lines on Mac Screen | Get Rid of Lines on Mac Screen in 2022

Using Terminal

To check disk permissions using Terminal, follow these steps,

Ways to Fix the Zsh Permission Denied Error in Mac Terminal

Step 1 Open Terminal and type the following command, ls -l . Add a space after the command and do not press Enter yet.

Step 2 Now, find the file that is causing the issue with Zsh. Open the file and then drag it into the Terminal window. 

Step 3 Press Enter.

Step 4 If you see rwxr before your username in the result, it means you have access to read, write, and execute commands to the file. However, if there is only ‘r’ in from of your username, then it is a read-only file and so Zsh commands won’t work. Similarly, w is write-only and xr is executable. 

Using Finder

To check disk permissions using Finder, follow these steps,

Step 1 Open the file using Finder.

Step 2 Now, press Command + I to open Get Info. Now check Sharing & Permissions at the bottom.

Step 3 Click on the arrow to the left of Sharing & Permissions and then check for Privilege.

If it says Read & Write then you have the necessary access to use Zsh commands. However, if it’s Read Only, you will face the Zsh Permission Denied error.

Change Directory Ownership to Solve Zsh Permission Denied

Since the user determines Read & Write access for a file, changing the ownership of a file might help fix the Zsh Permission Denied error. Follow these steps to do the same,

Step 1 Open Terminal.

Step 2 Enter this command, chown -R $USER:$USER /path/to/directory. $USER is the currently logged-in user, and the /path/to/directory is the location. 

Grant Terminal with Access to the Disk

Sometimes Terminal might not have the necessary access which can cause the Zsh Permission Denied error.

Follow these steps to check Terminal access and to provide access if it doesn’t,

Step 1 Open System Preferences on your Mac.

Step 2 Select Security & Privacy.

See also  The 7 Best Apple Watch Strap for Swimming in 2022

Step 3 Now, click on the Privacy tab. Then select Full Disk Acess.

Step 4 Click on the lock icon in the bottom left of the window. Enter your admin password if asked.

Step 5 Now, select Terminal from the list and check the box next to it so that it has full access. 

Note: Terminal might not be on the list on newer macOS versions. You have to add it manually. Click on the + button and search for Terminal in the search bar. Restart the Terminal to apply the changes.

Use Sudo Commands to Fix Zsh Permission Denied Error

If you still face the Zsh Permission Denied, error, then you should try Sudo commands. Sudo command is like a superpower. Sudo stands for superuser do and super users can execute commands as another user too. It will ask for the password first. 

Using superuser do commands is simple, just open Terminal and type any sudo command you want.

For this particular issue, try the following commands in Terminal,

sudo chmod 755 ~/Themes/ObsidianCode.xccolortheme

sudo chmod 755 /dvtcolorconvert.rb

Is There a Way to Prevent Terminal Permission Denied Errors on Mac?

Yes, you can try a few things to prevent this error. There are four preventive methods for this, check them out below.  

Assign Permissions to Users and Groups

Providing permissions to users and/or groups will prevent them from facing Zsh Permission Denied error. Follow these steps to assign permissions to users and groups,

Step 1 Select a file, folder, or disk on your Mac, and then click on File (Top Left corner) and select Get Info.

Step 2 Now, tap on the lock icon in the bottom left corner. 

Step 3 Now, from the Name column under the Sharing & Permissions section, select a User or Group. Now you can choose the access you want to give to the user or group.

This is what each permission means, 

Read Only: You can only read or access the file, folder, and disk. You cant change it. 

Write Only: A user can only copy and move the items but cannot access them. 

Read & Write: This allows users to access, edit and move the file or folder.

Grant Permissions to All Items in a Folder

You can also give permission to a folder or disk so that it can be accessed by specific users or groups. This will prevent the users or groups from encountering the Zsh Permission Denied error. Just do the following,

See also  How to Screenshot on iPhone | Take a Screenshot on iPhone in 2022

Step 1 Select a folder or disk. Then click on File (Top Left corner) and select Get Info.

Step 2 Click on the padlock icon in the bottom left corner. Enter password if required.

Step 3 Now check the bottom of the window and select Apply to Enclosed Items.

Step 4 Now, click on OK to save the changes. 

Change the Owner of an Item 

Sometimes, the Zsh Permission Denied error in Mac Terminal can be caused if the owner of the file or folder is a different user. To fix this, you can change the owner of the file. Follow these steps,

Step 1 Select the file or folder. Then click on File (Top Left corner) and select Get Info.

Step 2 Now add a new owner by clicking on the Add (+) button. 

Step 3 Then click on Make (user) as the owner. 

Step 4 Save the changes. 

Add or Remove a User or Group

Adding or removing users and/or groups can fix permission issues. Follow these steps to add or remove a user or group

Step 1 Select the item. 

Step 2 Click on File (Top Left corner) and select Get Info.

Step 3 Under Sharing & Permissions, click on + to add a user or group. Click on – to remove a user or group.

Step 4 Now, click OK to apply changes. 

How to Fix Zsh Permission Denied in Mac Terminal – Conclusion

And that is it. I have explained what causes Zsh Permission Denied error in Mac Terminal and how to fix the issue as well. 

To summarize, the cause can be due to a locked file or missing permissions. So check if the user has the required permission and access to make changes to a file, folder, or disk. To fix this you can change ownership of a file or grant access to the user. 

We hope this guide on How to Fix Zsh Permission Denied in Mac Terminal was helpful in fixing your problem. 

Also Read: