This article was reviewed by Stan Kats and by wikiHow staff writer, Megaera Lorenz, PhD. Stan Kats is a Professional Technologist and the COO and Chief Technologist for The STG IT Consulting Group in West Hollywood, California. Stan provides comprehensive technology solutions to businesses through managed IT services, and for individuals through his consumer service business, Stan's Tech Garage. Stan holds a BA in International Relations from The University of Southern California. He began his career working in the Fortune 500 IT world. Stan founded his companies to offer an enterprise-level of expertise for small businesses and individuals.
This article has been fact-checked, ensuring the accuracy of any cited facts and confirming the authority of its sources.
Did you run into a Zsh: Permission Denied error when trying to run a command or script in Terminal on your Mac? If so, don’t worry–these errors are usually pretty easy to resolve by fixing problems with your command syntax or changing your file permissions. In this article, we’ll explain what the error means, as well as the most common ways to fix it.
Steps
Changing Directory Ownership
-
Enter the chown command in Terminal. This method allows you to change the ownership of the file you’re trying to access, which may grant the missing permissions you need. In most cases, you must combine chown with the sudo command, granting you root/superuser privileges to execute the command. Enter the following text in Terminal:
- sudo chown -R $(whoami)
- Add a space after this command, but don’t press Return yet.
-
Drag and drop the file or folder into Terminal. This will cause the correct file path to appear after the command. Press Return to execute the command.
- At this point, you’ll be prompted to enter your password. You won’t be able to see it as you’re typing it in. Press Return when you’re done.
- Once you’ve successfully executed the chown command, try running the problematic command or script again. This time, you might not see the Zsh: Permission Denied error.
Granting Full Disk Access to Terminal
-
Open System Settings. Sometimes the problem isn’t with your user privileges, but with Terminal itself. If Terminal doesn’t have full access to your hard disk, it may not be able to execute certain commands. To grant full access, start by going to Apple menu > System Settings in the toolbar at the top of your screen.
-
Click Privacy & Security. It’s in the menu bar on the left side of the window.
-
Select Full Disk Access. In older versions of macOS, you might need to click the Privacy tab at the top of the window first.
-
Toggle on the switch next to Terminal. If you don’t see Terminal in the list, click the + button at the bottom of the list of apps and utilities. Enter your password or use Touch ID to verify your identity when prompted. In the window that opens, navigate to Applications > Utilities and select Terminal, then click Open to add it to the list.
- Once full disk access for Terminal is on, try again to execute your command.
Expert Q&A
Tips
-
When attempting to run commands in Terminal, it’s usually best to be logged in as an administrator on your Mac.Thanks
-
If you continue to run into problems, it might help to completely quit and reboot Terminal. You can also try restarting your Mac.Thanks
-
Most of these solutions also work in the Linux command line.Thanks