This short article explains what the “zsh: permission denied” message means on a Mac and how to clear that roadblock so you can run a file or command without trouble.
Often this error appears when the system can’t execute a file because it lacks execute rights, the file is locked, or the command is misformatted. A quick check with ls -l shows whether a file is read-only (r) or has full rights (rwx).
You’ll see simple fixes here: add execute permission, change ownership with chown -R username:username [directorypath], or give Terminal Full Disk Access via System Settings > Privacy & Security > Full Disk Access. Dragging a file into the Terminal after typing ls -l helps avoid typos and auto-fills the path.
Follow these steps and you’ll diagnose the problem fast, update permissions safely, and prevent this denied error from interrupting your workflow.
Understand what “permission denied” means in Zsh and why it happens
You’ll see this alert when the shell blocks a script that lacks executable bits, when a locked item prevents access, or when a command points at the wrong path.
What the message signals: The shell stops an operation because your account lacks the rights needed to run a file or because the command syntax is incorrect. This protects your system from unwanted changes.
Common causes include a locked file, a missing execute bit on a script, or a command that references the wrong path. Check file permissions with ls -l in a terminal window by typing ls -l, adding a space, and dragging the file into the window.
- Use Finder’s Get Info and expand Sharing & Permissions to view who can read or write a file.
- If only an r appears in the permission string, you can read the file but not modify or run it.
- Files moved from another disk or user may keep ownership that doesn’t match your account and will cause a denied error.
- Add Terminal to Full Disk Access under System Settings > Privacy & Security > Full Disk Access when commands fail due to restricted locations on disk.
Quick tip: Confirm the exact path and validate command syntax before changing file permissions or ownership.
Quick checks before you change permissions
Run a few fast checks in your shell so you spot typos or a wrong path before altering access settings. A tiny mistake can cause a permission denied message and waste time.
Verify location and names: use pwd to confirm your directory. Then run ls -l to list items and their access bits.
- Make sure the command is spelled correctly and points at the right path; one wrong character can cause an error.
- Type
ls -l, add a space, then drag the file or folder from Finder into the terminal window to insert the exact path directory. - Check for spaces in names. Quote paths or escape spaces so the shell reads the file correctly.
- Use tab-completion and copy a full command to a fresh line if a command still fails; hidden characters can break execution.
| Check | Action | What to look for | Next step |
|---|---|---|---|
| Working folder | Run pwd |
Matches expected directory | Proceed with ls -l |
| File listing | Run ls -l |
Shows file and access flags | Confirm target item |
| Path accuracy | Drag item into window | Exact path directory appears | Avoid manual typos |
| Name format | Check for spaces | Unescaped spaces cause errors | Quote or escape path |
How to Fix the “zsh: permission denied” Mac Terminal Error
You may see a block when a file lacks an execute flag, belongs to another user, or sits inside a restricted disk area. Start with a clear check before changing anything.
Check file permissions with ls -l and interpret rwx
Run ls -l [path] and read the left column. The letters rwx mean read, write, execute. A lone r is read-only. Drag a file into the shell after typing ls -l to avoid typos.
Adjust Sharing & Permissions in Finder’s Get Info
Right-click an item and open Get Info. Expand Sharing & Permissions, select your user in the name column, and set Read & Write if needed. This fixes many permission denied error cases without using the shell.
Make a file executable with chmod and verify access
Run chmod +x /path/to/file, then re-run ls -l to confirm an x appears for your account. Quote paths with spaces or escape them to keep the command correct.
Change ownership with chown and grant full access when needed
If ownership is wrong, use chown -R username:username [directorypath]. For protected folders, open System Settings > Privacy & Security > Full Disk Access, add Terminal, then quit and relaunch. These steps restore access and resolve many zsh permission denied situations.
- List first with ls -l.
- Use Get Info to set Read & Write.
- Add execute with chmod +x.
- Fix ownership with chown -R.
Step-by-step workflows for common scenarios
This short guide gives clear steps for the three routines you’ll use most often when a file or folder won’t run.
When a script or command won’t run: add execute and retry
Set execute bits: run chmod +x "/exact/path/to/script" for the target file. Use quotes when names include spaces.
Confirm the change with ls -l. Look for an x in the permissions string before you run the command again.
When a folder blocks access: apply fixes recursively
Open Get Info, set your account to Read & Write, then click Apply to enclosed items so all files inherit the update.
If you prefer the shell, use chown -R yourUser:yourUser "/path directory/that/needs/fix" and then recheck permissions with ls -l.
When ownership is wrong after moving items
Files moved between disks often keep previous ownership. Correct this by changing ownership and ensuring the correct group on shared folders.
After a chown -R, verify access for your user and run the failing command again. If a denied error remains, recheck the path for typos and confirm the file exists at that path directory.
- Set execute:
chmod +x "/exact/path/to/script". - Verify with
ls -lbefore retrying any command. - Use Get Info and Apply to enclosed items for folder fixes.
- Use
chown -Rwhen ownership mismatches follow a move.
| Scenario | Quick command or action | Verify |
|---|---|---|
| Script won’t run | chmod +x "/path/to/file" |
ls -l shows an x |
| Folder blocks access | Get Info → Read & Write → Apply to enclosed items | Files inside inherit read write |
| Ownership wrong | chown -R yourUser:yourUser "/path directory" |
User owns files; re-run command |
Pro tips to prevent the denied error going forward
Make default file and folder rules part of every new workspace. Set sharing permissions in Finder’s Get Info for project folders, choose sensible Read & Write values, and click Apply to enclosed items. This ensures new files inherit consistent file permissions and reduces future access surprises.
Assign the right users and group for shared directories. Use the Name column when granting roles so collaborators get the access they need without opening wider rights than required.
- Standardize file permissions on main project folders so every file folder inherits Read & Write for the right users and group.
- Make a path hygiene habit: quote paths with spaces and use tab-completion to avoid typos in commands on a terminal mac.
- Grant Terminal full access under Privacy & Security only if your workflow needs protected disk areas, and document who has that capability.
Quick checklist
| Task | Why it matters | Action | Verify |
|---|---|---|---|
| Set defaults | New items inherit safe rights | Get Info → Sharing & Permissions → Apply to enclosed items | ls -l shows expected bits |
| Group alignment | Avoid collaborator conflicts | Assign correct group and users | Users can read and write shared files |
| Path hygiene | Prevents malformed commands | Quote paths, escape spaces, use tab-complete | Commands run without path errors |
| Protected areas | Blocks when not granted | Privacy & Security → Full Disk Access for Terminal | Access file operations succeed |
Conclusion
, This short recap gives a clear checklist you can follow when a blocked command halts work.
First, validate rights with ls -l. Then use Finder’s Get Info and adjust Sharing & Permissions for your user. Make scripts executable with chmod +x.
Fix ownership with chown -R username:username [directory] when files move between disks. Grant Terminal Full Disk Access from System Settings > Privacy & Security only when required.
These steps solve most zsh permission issues. For recurring permission denied error messages, run the same checks in a menu or window and repeat basic commands before deeper troubleshooting. Keep a note of why full access was enabled so system rights stay secure.
FAQ
What does “permission denied” mean in zsh and why does it appear?
This message means the shell can’t read, write, or execute a file or folder with your current user rights. Common causes include files without execute bits, wrong ownership after moving data, locked items in Finder, or Terminal not having Full Disk Access under System Settings › Privacy & Security.
How can I quickly check the file or folder status before changing anything?
In Terminal run pwd to confirm your path and ls -l to list permissions and ownership. Verify the file name and any spaces or special characters are correct. A small typo or missing space often triggers a denied message.
What do the rwx letters in ls -l results mean?
rwx stands for read (r), write (w), and execute (x). They appear for user, group, and others. If a needed x is missing for scripts or binaries, add execute permission with chmod.
How do I make a script executable using a command?
Use chmod +x /path/to/file to add execute permission. Then run ./filename or the full path. Always confirm with ls -l afterward to ensure the x bit is set.
When should I change ownership and how do I do it?
Change ownership if files belong to another user or a different account after moving between disks. Use sudo chown -R yourusername:staff /path/to/folder to set your user and common group, then recheck with ls -l.
How can I fix folder access that affects many files at once?
Apply recursive changes: chmod -R for permission adjustments or sudo chown -R for ownership. In Finder’s Get Info, use Sharing & Permissions and click the gear to apply changes to enclosed items when available.
When should I grant Terminal Full Disk Access and how?
Grant Full Disk Access when macOS blocks Terminal from certain directories (like Desktop, Documents, or external drives). Open System Settings › Privacy & Security › Full Disk Access, add Terminal, then restart Terminal for changes to take effect.
What if a simple command still returns denied after permissions look correct?
Recheck the path for hidden characters, run file /path/to/target to confirm type, and ensure the interpreter (bash, python, etc.) is present and executable. Also confirm you’re not trying to run a directory or a non-executable file.
How do I fix issues caused by spaces or special characters in a file name?
Escape spaces with a backslash (My File) or wrap the path in quotes (“My File”). Mistyped paths or missing escapes lead to zsh interpreting parts of the name as separate tokens, causing denied errors.
Any tips to prevent this problem in the future?
Keep consistent ownership when copying files, set sensible default umask and permissions, use clear paths without unnecessary spaces, and add Terminal to Full Disk Access when you need frequent access to protected folders.
