[Fixed] Operation not permitted in macOS Terminal (TCC & Full Disk Access): Step-by-Step Troubleshooting Guide

Quick Summary: The error Operation not permitted (Errno 1 / EPERM) in macOS Terminal occurs even when running commands with sudo if macOS’s Transparency, Consent, and Control (TCC) privacy framework blocks your terminal app from accessing protected user directories (such as ~/Desktop, ~/Documents, ~/Downloads, or Mail/Time Machine backups), or when System Integrity Protection (SIP) locks down system directories like /System and /usr.

Understanding the Root Causes

  • Missing Full Disk Access (TCC): Your terminal emulator (Terminal.app, iTerm2, Warp, Alacritty, or VS Code’s integrated terminal) has not been granted Full Disk Access in System Settings, blocking access to protected folders and crontab.
  • System Integrity Protection (SIP): Attempting to write, symlink, or modify files inside Apple-protected system paths (/System, /usr/bin, /bin, /sbin), which remain read-only even for root.
  • macOS Extended Attributes (Immutable / Quarantine Flags): Files tagged with the uchg (user immutable) or schg (system immutable) BSD flags, or restricted by com.apple.quarantine.
  • SSH / Remote Login Sandbox: Connecting via SSH when sshd-keygen-wrapper lacks Full Disk Access.

Step 1: Quick Fix – Grant Full Disk Access to Your Terminal App

If your command fails when reading ~/Documents, ~/Desktop, ~/Library, external drives, or running cron jobs, grant Full Disk Access through macOS System Settings:

  1. Open System Settings (Apple menu → System Settings).
  2. Navigate to Privacy & Security → Full Disk Access.
  3. Click the + button (or toggle the switch) for your terminal application:
    • Terminal.app (in /System/Applications/Utilities/)
    • iTerm.app, Warp.app, or Visual Studio Code.app
    • If running commands remotely over SSH, also enable sshd-keygen-wrapper.
  4. Completely quit (Cmd + Q) and reopen your terminal application for the TCC permission change to take effect.

Step 2: Reset Corrupted TCC Permissions or Clear BSD Immutable Flags

If you previously clicked “Don’t Allow” on a macOS folder access prompt, or if a specific file is locked by BSD file flags rather than TCC, reset the prompt or clear the flags in Terminal:

# 1. Reset macOS TCC privacy permissions for Terminal (forces macOS to re-prompt cleanly)
tccutil reset SystemPolicyAllFiles com.apple.Terminal
# For iTerm2:
tccutil reset SystemPolicyAllFiles com.googlecode.iterm2

# 2. Check if a specific file has BSD immutable flags (uchg / schg) or quarantine attributes
ls -lO /path/to/target_file
xattr -l /path/to/target_file

# 3. Remove the user-immutable (uchg) and quarantine flags
chflags nouchg /path/to/target_file
xattr -d com.apple.quarantine /path/to/target_file

Step 3: Use /usr/local or /opt/homebrew Instead of SIP-Protected Paths

If Operation not permitted happens while attempting to install binaries or create symlinks in /usr/bin or /System, the command is blocked by System Integrity Protection (SIP). Rather than disabling SIP, place custom tools in Apple-approved writable paths:

# Check current SIP status
csrutil status

# Instead of writing to /usr/bin (SIP-protected), use /usr/local/bin or /opt/homebrew/bin:
sudo mkdir -p /usr/local/bin
sudo ln -sf /path/to/mytool /usr/local/bin/mytool

# Verify /usr/local/bin is in your shell PATH
echo "$PATH" | tr ':' '\n' | grep -E "/usr/local/bin|/opt/homebrew/bin"

Verification & Testing Steps

Restart your terminal session and verify that protected directories and restricted commands execute cleanly without Operation not permitted errors:

# 1. Test listing a TCC-protected directory
ls -la ~/Library/Safari/ || ls -la ~/Documents/

# 2. Verify crontab access (often blocked without Full Disk Access)
crontab -l

# 3. Verify file flags are cleared on target files
ls -lO /path/to/target_file

Troubleshooting Summary Comparison

Failing Location / Command Primary Root Cause Recommended Solution
~/Documents, ~/Desktop, ~/Library, crontab Terminal lacks Full Disk Access in TCC Enable terminal app in Privacy & Security → Full Disk Access
Denied after clicking “Don’t Allow” Cached TCC denial for Terminal/iTerm2 Run tccutil reset SystemPolicyAllFiles <bundle_id>
Modifying /usr/bin or /System Blocked by System Integrity Protection (SIP) Target /usr/local/bin or /opt/homebrew/bin instead
Single file cannot be edited/deleted BSD uchg immutable flag set on inode Run chflags nouchg <file>

Leave a Reply