Zsh: Permission denied Terminal error

367.2K views
11 min read

It's simple to open a file with macOS. Just double-click on it, and you're done! Another option is to use Terminal. Simply execute a command and specify the location of the file. 

However, this isn't always the case. When opening a file on Mac via Terminal, you can occasionally receive the "zsh: permission denied" message. This error can't be caused by a simple command. Instead, this indicates that something is amiss with your file or macOS.

In this article, we'll show you how to fix a "Terminal permission denied" problem.

Before we go into the details of the "zsh permission denied" issue on your macOS command line, let's clarify some basic terms.

What is Mac Terminal?

Mac's Terminal app is frequently used to operate your device with a variety of commands. To use it, you only need to be familiar with fundamental functions and commands, which you can then enter into the command line. 

For example, if you want to move a system file from one folder to another, you must use the move command "mv" and specify the destination folder.

Why do people use Terminal?

Mac users prefer Terminal for a variety of reasons. First of all, it's a fast way to run processes and tasks for those familiar with Unix commands. The other major advantage of utilizing Terminal is that it allows you to access parts of macOS that are hidden and not accessible through System Preferences.

How do you open it?

Go to Finder > Applications > Utilities folder, then double-click Terminal.

Open Terminal app

You can also press Command + Space to launch Spotlight. Then type “Terminal” and double-click it from the results.

If you use iStat Menus for monitoring features, you can also open Terminal from there. It’s available from the Disks category.


Why are you getting the permission denied error in Terminal?

If you see an error message like this, it means Terminal is unable to perform the command you’re attempting to run.

permission denied error

This usually happens because:

  • The file is locked. It's possible that you don't have administrator access or that the file's creator used chmod to lock it.
  • The command you're trying to run has been formatted wrongly.

How to fix Zsh permission denied error on Mac?

Below are a few methods you can try to fix the issue.


Check your permissions 

To check the permissions, follow the steps below:

  1. Open Terminal from the Mac's utilities menu  
  2. Type the following command: ls -l. Make sure to add a space after the final character
  3. Then find the file or folder you're working on and drag it into Terminal
  4. Now press the Return key. It'll display specific permissions that are available to the current user. You can read, write, and execute the file if the letters "rwxr" appear in the string of characters before your username in the result. If you just see one letter, such as "r," the file is read-only for you.

Permission settings determine who can view and alter files on the computer. Next, we’ll show you how to change the permissions.


Modify the file permissions 

If the "permission denied" terminal problem is caused by the permissions you just verified not allowing you to write to a file, try to repair it. To do so:

  1. Right-click the folder or file you're working on > Get Info
  2. Click the arrow if the information in Sharing & Permissions isn't accessible
  3. In the Name column, choose a user or group, then select a privilege setting from the pop-up menu

Change directory ownership

If changing permissions didn't resolve the issue, try changing the directory's ownership to your username. Change [username] to your username and [directorypath] to the path of the directory you wish to change ownership of in the steps below – you can just drag the folder onto the Terminal window as we did previously.

  1. Use command: chown -R $ [username] : [username] [directorypath]
  2. Press Return

Give Terminal complete control over the disk

It's also possible that the Terminal doesn't have full access to the drive, which is why you can't use commands to open the file. To change this, go to System Preferences > Security & Privacy > Privacy panel, and then add Terminal to the list of apps that can control your Mac.

What else can you do to resolve the "zsh: permission denied" issue?

Another method you can try is to use Mac's Terminal alternative – Core Shell. This terminal emulation app will allow you to customize your terminal to be precisely what you want it to be: useful, minimal, and attractive.

With this tool, you can run any commands, just like with the native Mac Terminal. The app has a great user interface which you'll enjoy. Core Shell also supports one-click login on remote computers with auto-reconnect capability. But what you'll probably like the most is the ability to change the look and feel of your terminal. You can change the color scheme of connections by using your favorite shades.

A colorful terminal app


We also suggest taking advantage of Almighty. It’s a native Mac software that aims to increase your productivity by giving simple modifications and extra functions. For example, it’ll let you keep your Mac awake to prevent it from idle sleeping, lock your keyboard to avoid obscure keyboard input, hide all apps and menu bar items, show hidden files in Finder, and much more.

It's a native Mac software that aims to increase your productivity by giving simple modifications and extra functions. For example, it'll let you:

  • Keep your Mac awake to prevent it from idle sleeping
  • lock your keyboard to avoid obscure keyboard input 
  • hide all apps and menu bar items
  • show hidden files in Finder 
  • and much more

You can do these tweaks via the command line, but it's tedious, and you must remember all the commands. With Almighty, you save time to do some other important tasks.

Almighty


"Zsh: permission denied" error: issue resolved

Permission issues with the file or directory you want to work on are frequently the cause of the "zsh: permission denied" error in Terminal. You may generally fix it by re-assigning ownership or altering permissions. If it doesn't work, try using Core Shell and Almighty

Both apps will arrive with Setapp, a suite of tools for solving everyday tasks on Mac and iPhone. You can use them 7 days free, then $9.99/mo.

240+ apps for $9.99
per month

Sign up to Setapp and try them for free.

Security-tested