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
Method 1: Grant Full Disk Access to Terminal (Recommended)
- Click the Apple menu > System Settings > Privacy & Security.
- Scroll down and click Full Disk Access.
- Toggle the switch ON for Terminal (or iTerm2).
- If Terminal is open, click Quit & Reopen.
- Re-run your
rmdeletion command in Terminal. It will now succeed.
Method 2: Clear File Flags (chflags)
Sometimes macOS files have an immutable flag set that prevents deletion:
- Open Terminal.
- Run
chflagsto remove the locked flag:
chflags -R nouchg /path/to/locked-file-or-folder
- 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:
- Shut down your Mac.
- Hold down the Power Button (on Apple Silicon M1/M2/M3) or
Cmd + R(on Intel Macs) until Recovery Mode loads. - Open Utilities > Terminal.
- Disable SIP:
csrutil disable
- Restart your Mac. (Note: Re-enable SIP after deleting by running
csrutil enablein 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.
Related Guides
- Learn about macOS System Data Cleanup.
- How to clear macOS Library Caches.
Discussion
Loading authentication...