Sudo On Mac Without PasswordHow to run sudo without the password prompt on your Mac.

We’ll cover updating your Mac’s /etc/sudoers file and user group for your account to allow you to run the sudo command without receiving the password prompt.


What is sudo?

In a nutshell, sudo is a program that gives you access to perform high-level operations and bypass the systems security limitations. Ever notice when you try to move or delete a certain file on your Mac that you’re prompted to enter your password? Hence, this is basically the system running the sudo command in the background to move or delete that file.

sudo (/ˈsuːduː/ or /ˈsuːdoʊ/ ) is a program for Unix-like computer operating systems that allows users to run programs with the security privileges of another user (normally the superuser, or root).

https://en.wikipedia.org/wiki/Sudo

Removing The Password Prompt

Open up the Terminal program on your Mac and enter the following command:

sudo nano /etc/sudoers 

You’ll be prompted for your password, enter it accordingly and press ENTER.

At this point, we’re looking at the contents of /etc/sudeors. Scroll down with your arrow keys or using CTRL + V to the bottom of the file until you find the following lines:

# Same thing without a password
# %wheel  ALL=(ALL) NOPASSWD: ALL

Remove the # from in front of the line starting with %wheel so that the line in your file now looks like this:

Enter CTRL + X then type Y and press ENTER to save and close the file.

Now we should be back at the command prompt. Enter the following command:

sudo dscl . append /Groups/wheel GroupMembership {{username}}

Make sure to replace {{username}} with your the username that you wish to grant access to sudo without the password prompt.

For my account (sgarbesi) it looks like this:


Looking Back

Now you should be able to run the sudo command without a password prompt from here on out. This has been tested and confirmed to be working on Mac OS X Mavericks.

About Salvatore Garbesi