MacOS – How to run a program as root without “sudo”

macosrootSecuritysetuidsudo

I have a certain binary program on OS X that can only be run as root.

I'm tired of prepending sudo each time I invoke it and typing the password, and would like it to automatically run as root when I invoke it regularly, without asking for a password.

The program's owner is root and its group is wheel.

I tried chmod ug+s to set the userid and groupid upon execution to root/wheel, but when I run the program without sudo it still complains that it can only run with sudo or as root.

Best Answer

Are you sure that the program you are trying to execute is actually a binary, and not a shell script. Most shells ignore suid scripts because they are really, really hard to do safely. An easy way to check is to use the file command on the program.

Related Question