Safe to Delete

How to Fix 'Operation Not Permitted' When Deleting Files on macOS

Quick Answer: Fix Terminal 'Operation not permitted' errors when deleting files on Mac by granting Full Disk Access or managing SIP permissions.

Bottom Line: When Terminal returns rm: cannot remove: Operation not permitted on macOS Sonoma, Sequoia, or Ventura, it does not mean you lack root/sudo permissions. It means macOS System Integrity Protection (SIP) or Privacy Permissions are blocking Terminal from accessing protected system folders (like ~/Library/Mail, ~/Library/Messages, or /var/protected).


Why Does macOS Block File Deletion?

Starting with macOS Mojave and enhanced in macOS Sonoma and Sequoia, Apple introduced System Integrity Protection (SIP) and TCC (Transparency, Consent, and Control). Even if you run sudo rm -rf, macOS blocks Terminal from modifying system containers unless explicit access is granted.


3 Methods to Fix ‘Operation Not Permitted’ on Mac

  1. Click the Apple menu  > System Settings > Privacy & Security.
  2. Scroll down and click Full Disk Access.
  3. Toggle the switch ON for Terminal (or iTerm2).
  4. If Terminal is open, click Quit & Reopen.
  5. Re-run your rm deletion command in Terminal. It will now succeed.

Method 2: Clear File Flags (chflags)

Sometimes macOS files have an immutable flag set that prevents deletion:

  1. Open Terminal.
  2. Run chflags to remove the locked flag:
chflags -R nouchg /path/to/locked-file-or-folder
  1. Delete the file using rm:
rm -rf /path/to/locked-file-or-folder

Method 3: Temporarily Disable SIP (For Protected System Directories Only)

If you need to delete protected system files inside /System or /usr:

  1. Shut down your Mac.
  2. Hold down the Power Button (on Apple Silicon M1/M2/M3) or Cmd + R (on Intel Macs) until Recovery Mode loads.
  3. Open Utilities > Terminal.
  4. Disable SIP:
csrutil disable
  1. Restart your Mac. (Note: Re-enable SIP after deleting by running csrutil enable in Recovery Mode).

Frequently Asked Questions (FAQ)

Does sudo rm -rf override ‘Operation Not Permitted’?

No. On modern macOS versions, sudo grants root user permissions, but SIP and TCC override root permissions for protected containers like Messages, Mail, and Time Machine snapshots.


Discussion

Loading authentication...

Related in macos

macOS Background Download Session Cache (com.apple.nsurlsessiond)

nsurlsessiond caches incomplete background file downloads for system apps and iCloud daemon sync. Clearing the cache is safe.

Safe to Delete

macOS Font Server Cache (/var/db/ats)

Apple Type Services (ats) caches font rendering metrics. Resetting the font cache fixes corrupted font glyphs and system text glitches.

Safe to Delete

macOS System Font Cache Directory (com.apple.fontd)

macOS caches system and user font rendering structures in com.apple.fontd. Learn how to reset macOS font cache to fix garbled text.

Safe to Delete
Back to all files