MacOS – sudo access to specific folder

macos

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)

Best Answer

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.