DEV Community

Xavier Font
Xavier Font

Posted on

Running sudo command without password (Mac OS)

0

I am running a script on my Mac on startup.

I would like to run the command sudo brew services start spotifyd but as you can see it uses root privileges, however I found no way of running the command so far without sudo.

Solving either of the following…

Top comments (1)

Collapse
 
maniflames profile image
Maniflames

The reason why you need to type sudo is to get permission for the action you'd like to take. If every piece of code could do anything it wanted all the time it would be very easy to hack you.

I looked around for a bit and you could configure your script as command that your specific user can run without a password. (stackoverflow)

However I'd suggest just starting it using sudo ./your-script-name so you can provide your password once up front so your whole script can run without asking for premission again for that specific command in your script.