Resolve command and permission errors in Terminal
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
Section 4 of 6:
Changing Directory Ownership
-
1Enter 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.
-
2Drag 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.
Advertisement
Section 5 of 6:
Granting Full Disk Access to Terminal
-
1Open 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.
-
2Click Privacy & Security . It’s in the menu bar on the left side of the window.
-
3Select Full Disk Access . In older versions of macOS, you might need to click the Privacy tab at the top of the window first.
-
4Toggle on the switch next toTerminal. 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.
Advertisement
Expert Q&A
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
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
Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!
Advertisement
About This Article
Advertisement