ClearDisk
Buy for $10Download ClearDiskDownload
A LITTLE MORE CLARITY

How to fix “Operation not permitted” in Terminal on Mac

“Operation not permitted” in Mac Terminal usually means macOS TCC privacy controls blocked your terminal app from reading a protected folder like ~/.Trash, a file has the user-immutable (uchg) lock set, or System Integrity Protection protects the path. Grant Terminal Full Disk Access in System Settings → Privacy & Security for user folders, or unlock the file in Finder Get Info.

What the message actually means

If ls ~/.Trash returns “Operation not permitted,” app privacy access is one thing to check. Owning a folder does not, by itself, give Terminal access through macOS privacy controls. Record the exact path and whether you were listing, copying or deleting: the message alone does not identify which protection blocked the operation.

For a privacy-access denial, sudo does not solve the problem. It changes the user running a command, not the app’s privacy authorization. Your Trash is one location where this can occur; Apple’s description of Full Disk Access names others, including Mail, Messages and Safari data and Time Machine backups. Desktop, Documents, Downloads and removable drives work differently: macOS asks the first time an app tries to use them.

1. Check the app’s privacy access

For Desktop, Documents or Downloads, check the terminal app under System Settings → Privacy & Security → Files & Folders first. If your task requires broader access to protected data, open Full Disk Access in the same settings pane. Click the add button (+), go to Applications → Utilities, select Terminal and click Open, then make sure its switch is on. macOS asks for your password or Touch ID. On macOS 12 and earlier, the same list is in System Preferences → Security & Privacy → Privacy.

Quit Terminal completely and open it again; the change applies after a relaunch, and System Settings may offer to quit it for you. If you use a different terminal, such as iTerm2 or the one built into VS Code, check that app instead, because access is associated with the app hosting the command. If a managed Mac prevents changes, ask its administrator rather than bypassing the restriction.

2. Test with a read-only command

After relaunching Terminal, test access without changing files. Do not automatically repeat a deletion or other modifying command. Both lines below only read: the first lists what is in your Trash, the second shows how much space it uses. A directory listing indicates that this app can read that location at that moment. If du prints a total alongside an access error, that total is incomplete. Neither result proves that you can safely delete the contents. Items in the Trash still occupy space until permanently removed; review them in Finder first.

If you only wanted a look, you may not need Terminal at all: the Trash in the Dock shows the same files, and Finder shows hidden items with Shift-Command-Period. The hidden-files guide covers the other dot folders you’re likely to look at next.

ls -la ~/.Trash
du -sh ~/.Trash

Why system folders stay read-only even then

Full Disk Access lets Terminal read your data; it doesn’t make macOS itself writable. System Integrity Protection restricts changes to protected parts of macOS, including /System and /usr/bin, even for root. Some locations remain writable for third-party software; do not infer that every path underneath /var or /usr has identical rules. The system itself also sits on a signed, read-only volume.

So “Operation not permitted” when you try to change something under /System or /usr/bin is expected, with or without sudo. Use ls -lOd to inspect a protected directory itself. A restricted flag is one clue; csrutil status reports whether SIP is enabled. These checks do not identify every possible access restriction. Don’t disable SIP to delete system files: it lowers the Mac’s protection, and those files are managed by macOS updates.

ls -lOd /System /usr/bin
csrutil status

Check a file lock before changing app permissions

If reading works but editing a particular file fails, select it in Finder and choose File → Get Info. Check Locked. In Terminal, ls -lO followed by a quoted file path shows file flags; uchg means the user-immutable flag is set. Unlock only a file you own and intend to change. A file lock is different from an app privacy denial.

On October 9, 2026, we created a disposable text file on macOS 27.0.1 and set its user-immutable flag. Finder showed Locked checked, and an attempted append returned “operation not permitted.” The original text remained unchanged. We then removed the flag from that test file. No personal file, system protection or Full Disk Access setting was changed.

This reproduces one cause of the error, not a privacy-access failure. Network shares, external filesystems, ordinary permissions and administrator policies need separate checks. Do not apply recursive chmod, chown or unlock commands to your home folder or the system just because one file failed.

Finder Get Info for our disposable locked-note.txt file, showing the Locked checkbox selected
Our generated sample file on macOS 27.0.1. The checked Locked box corresponds to the uchg flag; it is not a Full Disk Access setting.

3. Remove the access when you’re done

Full Disk Access is broad: Apple describes it as letting an app access all files, including other apps’ data, Time Machine backups and certain administrative settings for all users. Anything you run in Terminal, including a script you downloaded, runs with it. If you granted it for one task, switch Terminal off in the Full Disk Access list afterwards, or select it and click the remove button (–).

Keep only the access your ongoing work requires. If you turn it off, relaunch the terminal app before checking the restricted location again.

Common questions

Why does Terminal say Operation not permitted on Mac?

The message does not identify a single cause. Check the failed path and whether you were reading or changing it. App privacy access, a locked file and protected system locations require different fixes; Full Disk Access does not override them all.

Does sudo fix Operation not permitted errors on Mac?

No, for a privacy-access denial sudo doesn't help because it only changes which user is running the command, not whether the app has been granted access under macOS privacy controls. Grant the terminal app Full Disk Access, or the specific Files & Folders access, in System Settings instead.

Should I disable System Integrity Protection to fix a permissions error on Mac?

No. Keep SIP enabled. It protects parts of macOS even from root; Full Disk Access does not make the signed system volume writable. For a file you own, check its lock, app access and filesystem permissions instead.

How do I give Terminal Full Disk Access on Mac?

Open System Settings, then Privacy & Security, then Full Disk Access, click the add button, go to Applications then Utilities, select Terminal, click Open, and make sure its switch is on. Quit Terminal completely and reopen it afterward, since the change only applies after a relaunch.

References & further reading

These guides combine the linked official guidance with ClearDisk’s documented behavior. Your files and app settings determine the right next step.

Main guide: why is my Mac so slow and how low storage affects speed · Browse all Performance & memory guides →

FROM A NUMBER TO AN ANSWER

See what’s using
your space.

Explore your Mac with ClearDisk’s free local scanner.
Review the files. Keep the control.

Download free scannermacOS 15+ · version 2.2.1Cleanup license: $10 once