"Permission denied" in Mac Terminal (bash: /path/to/file: Permission denied or Operation not permitted) has several distinct causes — each needing a different fix.
Part 1. Use sudo for Administrator Commands
The most common cause: the command requires root (administrator) privileges.
Solution — add sudo before the command:
sudo chown -R username /path/to/folder
When prompted, enter your Mac user password.
⚠️ Important:
sudogrants root access — double-check the command before pressing Enter. A wrong path withsudo rm -rfcan delete critical system files with no undo.
Part 2. Fix File Permission Errors With chmod and chown
Check current permissions:
ls -la /path/to/file
Grant yourself read/write access:
chmod 644 /path/to/file # File: owner read/write, others read
chmod 755 /path/to/folder # Folder: owner full, others read/execute
chmod -R 755 /path/to/folder # Recursive — applies to all contents
Take ownership of a file:
sudo chown $(whoami) /path/to/file
sudo chown -R $(whoami) /path/to/folder # Recursive
💡 Tip:
$(whoami)automatically inserts your current username — you don't need to type it manually. More reliable than typing your username manually, especially if it contains spaces.
Part 3. Grant Full Disk Access for System Tools
macOS requires Full Disk Access for tools that need to read protected system areas (recovery software, backup tools, Terminal operations on protected locations):
- System Settings → Privacy & Security → Full Disk Access
- Click the
+button - Navigate to Applications → Utilities → Terminal
- Click Open — Terminal now has full disk access
🗣️ r/mac user: "Data recovery software kept getting permission denied on Mac. Added it to Full Disk Access in System Settings. Ran perfectly after that — recovered everything."
Part 4. Handle SIP-Protected Files
macOS System Integrity Protection (SIP) prevents modification of core system files even with sudo:
csrutil status # Check if SIP is enabled
For legitimate development or recovery needs (not routine use):
- Restart Mac and hold Power (Apple Silicon) or Cmd+R (Intel)
- Enter Recovery Mode → Utilities → Terminal
- Run:
csrutil disable - Restart normally, perform needed operation
- Return to Recovery Mode and run:
csrutil enable
🗣️ r/MacOS caution: "Only disable SIP temporarily for specific legitimate tasks. Re-enable it immediately after. SIP protects core macOS integrity — leaving it off long-term exposes the system to modification attacks."
Part 5. Common Permission Denied Scenarios and Fixes
| Error Context | Cause | Fix |
|---|---|---|
| Running a script | Script not executable | chmod +x script.sh |
| Accessing ~/Library | Hidden, needs explicit path | open ~/Library in Finder |
| Writing to /usr or /System | SIP-protected | Disable SIP temporarily |
| Recovery software denied | No Full Disk Access | Add to System Settings → Full Disk Access |
| File owned by another user | Wrong ownership | sudo chown $(whoami) file |
FAQ
What does "permission denied" mean in Mac Terminal? The current user lacks the necessary file system permissions to perform the requested operation. The fix depends on whether the restriction is from file ownership (chown/chmod), administrator privilege (sudo), Full Disk Access policy, or SIP protection.
How do I run a command as root on Mac? Prefix the command with sudo. Enter your administrator password when prompted. This elevates the command to root privilege for that single operation.
How do I make a file executable on Mac? Run chmod +x filename in Terminal. This adds execute permission, allowing the file to be run as a script or program.
Why does sudo still give permission denied? SIP (System Integrity Protection) prevents modification of certain system paths even with sudo. The error message usually includes "Operation not permitted" rather than "Permission denied." Disabling SIP temporarily (in Recovery Mode) is the only bypass.
