On OS X Mavericks, I want to install few files without prompting user for sudo password. (Folder where i am trying to install require root access because it is present at / location). I can do this by modifying "sudoer" file and disable sudo password but this is unsafe and open up security risk.

Is there any way I can provide sudo access only a particular folder? So when I try to write to this folder, sudo password prompt is not visible to user.

(All above task are done through command line)


Don't modify the sudoers file. It isn't necessary. I think what you mean is "is there anyway I can alter ownership and permissions so sudo isn't required?" Yes. You can modify the folder's permissions and ownership settings using Terminal. Note, you will have to use sudo to do so and the command must be run by an administrator.

sudo chown -R $UID:staff /path/to/folder; chmod -R 755 /path/to/folder; exit

Substitute "/path/to/folder" with the proper path. The "chown" command changes ownership of the directory to you (and it's subfolders, using the -R option). The "chmod" command sets the folder's permissions to readable/executable by everyone and writable by the owner (you) only.

  • That's what i am trying to avoid. While writing to a specific folder, i don't want any type of password to be prompt. I am trying to perform a silent installation and it's purpose is defeated if any (admin) password need to be entered. – iamMobile May 21 '14 at 18:30
  • @iamMobile the admin password is only needed once - to run the command. After that, you won't need it again. You wouldn't be able to change the sudoers file without an admin password, either, btw. – njboot May 21 '14 at 18:38
  • 1
    @iamMobile Being able to do this with no password prompt at all would be a massive security hole in OS X. – Andrew Medico May 21 '14 at 20:11
  • @AndrewMedico yes, it would defeat the whole purpose of the UNIX based permissions and ownership. – njboot May 21 '14 at 20:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .