Troubleshooting “zsh: operation not permitted”

If you try to run a script from the Terminal in macOS, you may get an error that says zsh: operation not permitted.

As of this writing, the top Google search results for that all point to needing to grant the Terminal full disk access (either via System Preferences > Security & Privacy > Privacy > Full Disk Access or via MDM-delivered PPPC profile.

If that works for you, great!

But it could also be that there is an Apple quarantine extended attribute on your script. Now, of course, don’t take that extended attribute off if you don’t trust the script. If you do trust it, though, you can remove that extended attribute.

To see the extended attributes, run

xattr -l /PATH/TO/

If you see in there, you can remove it by running

xattr -d /PATH/TO/

The only other thing you may want to check is that your script is executable:

ls -l /PATH/TO/

There should be some x‘s in there (read man chmod for more details).

If it’s not, you can add the executable flag to it:

chmod +x /PATH/TO/





25 responses to “Troubleshooting “zsh: operation not permitted””

  1. Jordano Avatar

    Thank you!

  2. Jim Avatar

    You saved me with this. I literally love you right now

  3. Teus Avatar

    That worked for me, thank you!

  4. Jamie Avatar

    Excellent. This was most helpful, thanks a lot.

  5. Oscar Avatar

    Great, I was dancing with chmod to no avail.
    Thank you!

  6. Yu Avatar

    Thank you!

  7. Glory Avatar

    Thank you for that. It seems a new problem because my script that written years ago still runs.

  8. Skippy Avatar

    Awesome, I don’t know why the flag got flipped on my script, but I was left scratching my head; not least since I used the script 5 minutes before…

  9. Sahil Avatar

    You saved me. Indebted

  10. Janosh Avatar

    Thanks! Sometimes Apple makes life difficult for devs.

  11. saghazade Avatar

    i am seriously thankful of you!

  12. Maria Avatar

    Thank you so much for the tip!

  13. Ben Avatar

    Very, very helpful. Thank you!

  14. musa Avatar

    thanks bro saved my day

  15. endyk Avatar

    Thank you. I’ve been searching everywhere for two days, and your advice is very very very helpful. I’m using all my *.sh files in Tomcat 9 shell script in the folder bin. Thanks again.

  16. pr Avatar

    Hey thanks for this it was great!
    In my case it was a BBEdit sandboxing issue:
    But I would not have solved that if it wasn’t for this page. Thanks!

  17. Gabri Avatar

    Many Thanks, you made my day man!

  18. Alan Avatar

    Thanks for sharing

  19. Melissa Avatar

    It worked! Thankss!!!

  20. Leif Stenfeldt Avatar

    Big help – Thank you.

  21. Cenk Avatar

    Thank you for solution. It works like a charm. 😀

  22. Kari L Avatar
    Kari L

    Big thanks! Works in Ventura!

  23. ryan Avatar

    Thank you!

  24. Christopher Hughes Avatar
    Christopher Hughes

    Thanks so much for this.

  25. Jyotsna Avatar


Leave a Reply

Your email address will not be published. Required fields are marked *