Some Mac users who use the Terminal may have experienced ‘Operation not permitted’ error message, which is a common command-line error for Mac users. Issuing even the simplest commands in the command line has prompted the error to appear. This error has also occurred when working in the user Home directory.

There have been many different situations where the user receives the error on Mac. However, there is a fix for that error on your Mac. This tutorial will show you how to test your Mac for the error and how to fix the error message.

Check your Mac for the Error

Test for the error on your computer with this command using ls in a protected folder:

Is ~/Library/Messages

If your computer Terminal does not have Full Disk Access permission, the ‘Operation not permitted’ error message will appear.

If your Terminal does have Full Disk Access permission, the error will not appear. Instead, you will get this result:

This is also the case when SIP is disabled. This solution basically adds additional access privilege to the Terminal in order to eliminate the error.

Fix ‘Operation Not permitted’ Error in Mac Terminal

The ‘Operation not permitted’ error can occur for a number of reasons. This solution addresses the access privileges in Terminal.

Turn on your Mac and go to Apple > System Preferences > Security & Privacy.

1. Select ‘Privacy’ and then select ‘Full Disk Access’ from the left panel menu.

2. Click on the lock icon and authenticate your activity by entering your administrator credentials.

3. Select the plus (+) to add applications to Full Disk Access:

4. Go to the /Applications/Utilities/folder and select ‘Terminal’. This will grant Terminal Fill Disk Access Privileges.

5. Reopen the Terminal. See if the error message has gone.

Use SIP to limit root account privileges

When you attempt to access these directories: /System, /bin, /sbin, or /usr you may get the ‘Operation not permitted’ error. Protected locations that will not allow you to mount another location are listed in /System/Library/Sandbox/rootless.conf on Mac. ‘Repair disk permissions’ has been removed from ‘Disk Utility’ options.

You can try disabling the System Integrity Protection (SIP), which came out with Mac OS X 10.11 in El Capitan as a file and process protection feature. SIP restricts what the root account can access and limits its permissions. However, disabling SIP should be the last resort and for the best reasons as it is a security setting. If you are not familiar with troubleshooting your computer, please refer to step #5.

SIP is stored in NVRAM on your computer and it must be modified in Recovery mode. Boot your Mac in Recovery mode by restarting and pressing down the Command + R shortcut keys as it reboots.

To disable SIP go to Utilities > Terminal and type the following command:

csrutil status

From here, you should be able to view whether SIP is disabled or enabled on the screen:

We can see in Terminal that SIP is enabled. To disable, type the following command:

csrutil disable

Restart your Mac for the change to take effect. The SIP will be disabled. Your computer should not have the access privilege problem now.

This method also works when MacOS Mojave privacy features limit access to certain files due to ‘Full Desk Access’ permissions issues. This problem has often been reported after upgrading Mojave.

If you need to re-enable SIP on your Mac, type the following command in Terminal:

csrutil enable

Restart your Mac. By typing this command and restarting, SIP is being re-enabled on your Mac with all of its restrictions.

Reset Home Folder Permissions

If disabling the SIP doesn’t work, try reseting your Home folder permissions. Changing the read and write permissions for items located in your Home folder may affect the permissions. If you believe the error message began after changing permissions for some of your Home folder items, use these steps to reset the Home folder permissions:

1. From Finder, go to Home > File> Get Info.

2. When the Info window opens up, click the triangle to open up Sharing & Permissions (if it wasn’t already open). Click the Lock icon and enter your administrator credentials.

3. Select the Action Menu down at the bottom of the window.

4. Click ‘Apply to enclosed items’ and then click on ‘OK’ to confirm.

5. The progress bar should appear. When it completes, go to Utilities > Terminal.

6. Type the following command:

diskutil resetUserPermissions / 'id -u'

7. Press ‘Return’.

8. When the process is complete, restart your computer.

With the permissions set back to default for your Home folder, go back and see if your read and write permissions have been reinstated.

Get Help from Apple Support

If you were not able to eliminate the ‘Operation not permitted’ error from your Mac using these steps, please contact Apple Support.