Mac

Zsh: Permission denied in Mac Terminal (A Complete Guide 2022)

Overview:

Sometimes, when you try to open a file or folder through Terminal, an error occurs, saying “zsh: permission denied:/”. You can’t access the file or folder.

zsh permission denied

Of course, you can also open a file or folder by locating and double-clicking it. However, if you had no idea about the location of the file as some files may be hidden, or you just wish to access the file in another way, it can also be an option to use Mac Terminal, a command-line interface that allows Mac users to execute different actions.

Terminal can be a useful tool for you to run different commands to change various settings, for instance, resetting NVRAM/PRAM. Unfortunately, the error, “zsh: permission denied: /” comes up when you manage to access a file in this command-line program, so you would better manage to fix this permission denied error on Mac.

What Does zsh Mean? What is the Error “zsh: permission denied:/” on Mac?

Zsh, also called the Z shell, refers to a Unix shell that is built on bash, the default shell on Mac devices. As for the features of Zsh, it works to configure themes and plugins as an interactive login shell to interpret commands for shell scripting. If you want to customize a theme for your MacBook Air or Pro, zsh is available. 

The error occurs when there are problems with the sudo or bash commands, in which the former is to allow users to run a command and the latter is a shell program that transforms a command to an API on macOS. Or you can simply understand this error as a permission denied issue.

Why Is zsh: permission denied in Mac Terminal?

In terms of reasons why the zsh permission is denied in Terminal, the problematic files and commands are to blame.

For instance, if the macOS has not permitted you to open a file via Terminal as you are not an administrator, it will show you Mac permission denied. Meanwhile, if the ownership of the directory of the command is incorrect such as the false chmod x command, chances are that “zsh: permission denied: ./” error appears.

How Do I Fix “zsh: permission denied:/” Error?

You need to check the permission of Terminal on your Mac device and give full permissions to it to ensure the Terminal permissions denial will not show up. Adding users and groups to the Terminal is also necessary to avoid the zsh permission denial issue.

Solutions:

Solution 1: Re-check the Permission in Terminal

When there is no permission for you to open a file through Terminal, the permission will be denied. In this case, you would better check whether you have permission to access and modify a file on Mac.

1. Open Launchpad and then type in Terminal in the top search box to open this program.

2. In Terminal, input the following command.

ls -l
li i to check terminal permissions

Remember that there is a space at the end of the command and don’t run the command now.

3. Drag and drop the file in Terminal to allow Terminal automatically detect the location of the fil and add the location.

4. Hit Enter.

In this way, you may have opened the file in Terminal.

However, if you have no permission, the zsh: permissions denied warning will pop up. If you can open a file via Terminal but run into “your account doesn’t allow editing on a Mac” when trying to modify the file in Office Word, you need to fix this Office account error. 

Solution 2: Grant the Terminal with Full Disk Permission

Some users reflected that there is no full disk permission on macOS. Hence, you may notice that Mac permission is denied when you are trying to access a file or folder. You can just manage to enable full disk access to ensure the files are available in Terminal.

1. In the top left corner of the Mac desktop, click the Apple icon and then select System Preferences.

2. In System Preferences, find out Security & Privacy.

3. Under Privacy, in the left pane, locate Full Disk Access and then check the box of Terminal on the right pane.

enable full disk access in privacy

Note:

If you have not found Terminal on the right pane, you need to hit the Lock icon at the left bottom and then enter your Password to unlock the settings to add Terminal to the list.

At this moment, you will have full permission to access all items in disks on Mac including files by Terminal. The Terminal permission denied error will disappear.

Solution 3: Change the Path of Directory

The ownership of the directory may also be a potential culprit for the zsh permission issue. Thus, you might as well try to adjust the path/ownership of the directory in Terminal to see if it works to solve the file permission error.

1. Open Terminal.

2. Then type in the following command in Terminal and then press Enter.

chown -R $USER:$USER /path/to/directory

You need to change $USER with your username now on the Mac, and /path/to/directory with the path to the file location.

The chow command on Mac is used to help users to change ownership and you need to have the administrative privileges to run the chow command. After you run the above command, you will have also changed the ownership or path.

Solution 4: Add the Sudo Command before the Original Command

The sudo command empowers Mac users to run commands with administrative privileges. Sudo, here, represents superuser do.

Therefore, if you hit upon Mac Terminal zsh: permission denied: ./ error, it is a feasible solution to place the sudo command before the original command to open a file or folder to gain more permissions.

1. In Terminal, input a command of sudo command + the original command.

Here, you are to open a file to check whether you can access the file like an application installer on MacBook Air or Pro, or any other Mac device.

2. Type in your password for this Mac device.

Check whether you can execute the original command with more permissions by the sudo command. In this case, you can configure the theme for your device, so the zsh permission denied error disappeared.

Solution 5: Give Permissions to Users and Groups

If you find that the zsh permission is denied in Mac Terminal, it may imply that you have no privileges to write a file. Therefore, you can attempt to assign permissions to a file or folder as you wish to read and write it on Mac. Of course, you can access this file in Terminal without the permission issue.

1. Go to Finder.

2. Locate the file or folder and right click it to Get info.

get info of a file

3. Uncheck the box of Locked to unlock the folder for setting modifications.

check the box of locked

4. Under Sharing & Permission, locate the username and then choose to allow a user or group to Read and Write the file or folder.

read and write privileges of a file

5. If required, you need to hit the Lock icon at the right bottom and enter your password before changing the file or folder permission.

Summary:

With the help of this post, you can apply different solutions to resolve the “zsh: permission denied” error on Mac. Do not worry, you can open a file or folder in Terminal next time after you try one or more solutions.

More Articles:

File and Print Sharing Resource is Online but Isn’t Responding to Connection Attempts (2022 Update)

How to Refresh on Mac (Desktop, Browsers, Email, Message)

Fixed: A Web Page is Slowing Down your Browser (Firefox)

Leave a Response