Fix Terminal “Operation not permitted” Error in macOS Monterey, Big Sur, Catalina, Mojave
If you’re a Mac command line user you may have noticed that many frequently used commands entered into the Terminal (or iTerm) result in an “Operation not permitted” error message since updating to MacOS Mojave 10.14 or later, including Monterey and Big Sur. The “Operation not permitted” error in the Terminal can be seen after issuing even simple commands like using ‘ls’ ‘mv’ and ‘cp’ within the users own directory, but also in many other directory locations on the Mac, and when trying to use many defaults commands. Obviously this type of error message makes navigating and using the command line in MacOS Mojave to be quite difficult if not impossible for many purposes. Don’t worry, the Terminal is not broken in new MacOS versions.
This walkthrough will show you how to fix “Operation not permitted” error messages seen at the command line in Terminal for Mac OS in Mojave 10.14 or later.
How to Fix “Operation not permitted” Error in Terminal for Mac OS
- Pull down the Apple menu and choose ‘System Preferences’
- Choose “Security & Privacy” control panel
- Now select the “Privacy” tab, then from the left-side menu select “Full Disk Access”
- Click the lock icon in the lower left corner of the preference panel and authenticate with an admin level login
- Now click the [+] plus button to add an application with full disk access
- Navigate to the /Applications/Utilities/ folder and choose “Terminal” to grant Terminal with Full Disk Access privileges
- Relaunch Terminal, the “Operation not permitted” error messages will be gone
If you have not encountered the “Operation not permitted” error message in the Terminal of MacOS (Mojave 10.14 or later) yet, then it’s likely because you haven’t wandered into a directory or file path that has the additional access restrictions (or that you don’t use Terminal, in which case this entire article is not for you).
While many of the various core System and root directories will throw error messages in macOS Terminal too, you can also find the error message even when trying to work in the users own Home directory, including in many of the user ~/Library/ folders, like ~/Library/Messages (where iMessage attachments and chat logs are stored in Mac OS) and ~/Library/Mail/ (where user-level mail plugins, mailbox data, and other Mail app data is stored), and many others.
You can test this yourself, before and after making the settings adjustment outlined above with a simple command like using ls on one of the protected folders:
If Terminal does not have Full Disk Access granted, you will see the “Operation not permitted” error message.
If Terminal does have Full Disk Access granted, or if SIP is disabled, you will not see that error message in the MacOS Terminal.
In case you were wondering, yes that does mean there are actually two ways to fix the “Operation not permitted” errors you may encounter in MacOS Terminal; the first which we detail here is rather simple that grants additional access privileges to Terminal app, and the other is a bit more dramatic which involves disabling System Integrity Protection on the Mac which is generally not recommended and we won’t specifically cover here, though simply disabling SIP and rebooting is typically enough to make the error go away if you’d rather go that route.
The “Operation not permitted” message is one of a variety of command line errors you may encounter in Mac OS Terminal. Another frequently seen command line error is the the “command not found” error message which can also be encountered in the Terminal for MacOS for a variety of different reasons as well.
If you have any other tips, tricks, suggestions, or thoughts about the command line in MacOS or this particular error message, share with us in the comments below.