Search code examples
macossudochmodptracedtrace

Cannot change permissions for dtrace on MacOS


I was looking at this article.

It recommends allow the usage of dtrace without root for current user, so I run:

$ sudo chmod u+s /usr/sbin/dtrace
Password: # I enter in my password
chmod: Unable to change file mode on /usr/sbin/dtrace: Operation not permitted

Does anyone know if I should, and how I should, allow dtrace to run without root permissions?


Solution

  • I'm not sure what article you were reading, but its advice is unsafe and incorrect. You should never change permissions on files stored in system locations, like /usr/bin and /usr/sbin. (Indeed, System Integrity Protection makes this impossible.)

    If you need to use dtrace, run it using sudo.