What's going on?
You try to move, edit, or delete a file in Terminal, and you get Operation not permitted. You might see it after chmod, rm, or mv. It's not a typo in your command. It's macOS blocking you at a deeper level.
This usually happens two ways: either the file's permissions don't match what you're running, or macOS's privacy protections are stopping Terminal from touching certain folders. The fix depends on which one you're hitting. We'll go from the 30-second check to the 15-minute reset.
First: the 30-second fix — check for extended attributes
macOS tags files with invisible metadata. One tag, com.apple.quarantine, gets added when you download a file from the internet. That tag can cause weird permission errors. You can see it with:
ls -lO file.txtLook at the uppercase letters after the permissions. If you see an @ at the end of the permissions line, you've got extended attributes. To strip them all off a single file:
xattr -c file.txtTo do it recursively on a folder:
xattr -cr foldernameAfter you run that, try your original command again. You should see it work. If not, move to the next step.
Second: the 5-minute fix — grant Full Disk Access to Terminal
If you're working in folders like Desktop, Documents, or Downloads, macOS protects them with privacy controls. Even if you're an admin, Terminal doesn't get automatic access. You have to grant it explicitly.
Here's how:
- Open System Settings (or System Preferences on older macOS).
- Go to Privacy & Security.
- Scroll down and click Full Disk Access.
- Click the + button. If it's greyed out, click the padlock and enter your password.
- In the file picker, press Cmd+Shift+G and type
/bin/zsh(or/bin/bashif you're using that). - Select it and click Open.
You should see Terminal or its shell listed. Toggle it on. Then quit Terminal completely (Cmd+Q) and reopen it. Try the command again.
That fixes it for most people. If you're still stuck, it's time to get deeper.
Third: the 15+ minute fix — reset permissions and your home folder
Sometimes the problem isn't privacy — it's that the file or folder has explicit permissions that lock you out. On macOS, the chmod command can set permissions, but if the file is owned by root or another user, you'll get nowhere. First, check ownership:
ls -l file.txtThe third and fourth columns show owner and group. If it's root and you're not, you need sudo. Use:
sudo chown yourusername:staff file.txtThen change permissions:
chmod 755 file.txtThat'll give you read, write, and execute. But what if even sudo throws Operation not permitted? This happens when System Integrity Protection (SIP) locks the file. You can check if SIP is on:
csrutil statusIf it shows enabled, you can't touch system files directly. You have two options: boot into Recovery and disable SIP (then re-enable it after), or use the proper macOS restores like tmutil for Time Machine backups or diskutil for disk management.
Disabling SIP is a real fix but only for truly stubborn files. Here's how: restart your Mac, hold Cmd+R until you see the Apple logo, open Terminal from the Recovery menu, and type:
csrutil disableRestart normally, make your change, then re-enable SIP the same way with csrutil enable. Leave it disabled and you're opening your Mac to malware. Not worth it unless you really know what you're doing.
The last resort is resetting the home folder permissions. That's a big hammer, so use it only if nothing else worked. Boot into Recovery (Cmd+R at startup), open Disk Utility, and run First Aid on your startup disk. Then restart and try your command.
Real-world trigger: This error shows up constantly after you download a script from GitHub, try to run it on your Desktop, and get hit with Operation not permitted even though you're admin. It's almost always the quarantine attribute or the Full Disk Access setting.Which fix is actually the common one?
In my experience fixing these for other people, 8 times out of 10 it's the Full Disk Access setting. Users don't realize macOS treats Terminal as a separate app that needs its own permission. The quarantine attribute is second, and SIP issues are rare outside of system files.
So start with xattr -c. If that doesn't do it, grant Full Disk Access. If you're still stuck, check ownership with ls -l and use sudo chown. Only then think about SIP.
One more thing: after any of these fixes, don't just assume it worked. Run the exact same command that failed. It should complete without the error. If it doesn't, you may be dealing with a different problem, like a corrupted disk or a permissions plist file gone haywire.
If you've tried all three and you're still seeing Operation not permitted, restart your Mac and try again. A fresh session can clear up weird cached permission states. That's free and takes a minute.