While working on the macOS command line, you can sometimes encounter an “Operation not permitted” error message. This then makes it difficult for you to navigate through the terminal and issue commands to your system.
Usually, a macOS security feature known as Full Disk Access is responsible for this error popping up on your screen. Disabling Full Disk Access can restrict you from accessing files in certain locations and directories. So when the terminal tries to access the particular file/folder, the system doesn’t permit it to run the command(s).
However, there are other factors to consider as well, and we shall skim past all those causes down below. But rest easy knowing that this problem can be solved by taking some very easy and surefire steps.
Why Am I Seeing This Error Message?
- Full Disk Access
- Locked Files
- An unsuitable file directory
- System Integrity Protection
What is “Operation not permitted” Error on Mac? How to Fix It
There are a few different ways to fix this error on your system. We shall go through all those ways, one step at a time. So, by the end of this article, we guarantee that you’ll no longer see this prompt on your terminal screen.
Enable Full Disk Access
You can give the terminal access to the entire disk through the System Preferences. Doing so will allow the system to modify files and folders present in every nook and cranny of your system. And then, you’ll no longer get the “Operation not permitted” error message.
- From the menu bar, go to Apple > System Preferences.
- Click on Security & Privacy settings.
- Click on the lock and enter your admin password to allow new changes.
- Navigate to Privacy.
- Select Full Disk Access from the left panel.
- Now, click ‘+’ to give selected applications full disk access.
- Select Terminal from the list of applications and Open it.
- Go back to Full Disk Access and make sure that the Terminal is marked for full access.
- If prompted, Quit & Reopen the terminal.
- Finally, click on the lock to save your changes.
Unlock Locked Files
If you’re trying to access a file via the terminal and notice that the operation is not permitted to continue further, chances are that the particular file is locked. A locked file cannot be altered or modified in any way. So, to prevent this ongoing issue, you can specify the file path in the Terminal and enter a set of commands to unlock it.
- Press Command + Space to open Spotlight.
- Type and go to Terminal.
- Enter this command:
chflags nouchg /*file path*
For e.g.chflags nouchg /Maschitosh HD/Library/Preferences/abc
- Type
exit
to exit the terminal.
Disable SIP
Like Full Disk Access, another macOS security feature known as System Integration Protection (SIP) can also influence disk permissions and operations. Apple implemented the SIP security standard on macOS to ensure that no system files are unnecessarily altered or modified.
However, you can easily bypass this security feature through the command line. But, we recommend you do so temporarily as the SIP works to maintain your system’s stability and its overall health.
The SIP has to be disabled before the OS fully loads up. Hence we’ll be accessing the macOS recovery window to enter a set of commands and disable SIP. So,
On Intel Macs
- Restart your computer.
- As soon as the system begins to start up again, hold Command + R until you see the Apple icon.
- Then, from the menu bar, go to Utilities > Terminal.
- Type
csrutil disable
and hit enter. - Then, enter
reboot
to restart your computer normally.
On Apple Silicon Macs
- Shut down your computer.
- Hold Power and startup your system.
- Release the hold only after you see the startup Options.
- Then, go to Options.
- Now, from the menu bar, go to Utilities > Terminal.
- Type
csrutil disable
and hit enter. - Then, enter
reboot
to restart your computer normally.
Now, if and when you want to enable the SIP feature, go to Utilities > Terminal the same way as mentioned above and run the csrutil enable
command instead.
Similarly, to check the SIP status of your device, run the command csrutil status
and look for either the ‘System Integrity Protection status: enabled’ or ‘System Integrity Protection status: disabled’ message.
Change File Directory
While skimming through various forums, we noticed that plenty of users encountered the “Operation not permitted” error message while trying to access a file in /usr/bin directory of your computer. Furthermore, for those users, transferring that particular file to /usr/local/bin seemed to fix the problem.
/bin stands for ‘Binary’. That is, this folder stores executable commands to execute certain functionalities on your installed application. Since a wrong move can greatly alter your app’s configuration setting, we recommend you follow this method if nothing else works.
- From the menu bar, click on Go > Computer.
- Select your main disk drive (by default, named Macintosh HD).
- Then, press Shift + Command + . (period) to view hidden files.
- Now, navigate to usr > bin folder.
- Copy the required file(s) and paste it on usr > local > bin folder.
- Restart your computer.