Sunday, March 31, 2013

set directory owner, group, and permissions on *nix machine

Execute the following commands via the command line:

sudo chgrp -R _www /Users/user_dir/target_dir
sudo chmod -R ug=rwx /Users/user_dir/target_dir
sudo find /Users/user_dir/target_dir -type d -exec chmod 2770 {} \;
sudo find /Users/user_dir/target_dir -type f -exec chmod ug=rwx {} \;
The first command sets the group to _www recursively.
The second command sets the owner and group permissions to rwx recursively.
The third command makes it so all new directories get created with the correct permissions (i.e. 2770).
The fourth command makes it so all new files get created with the correct permissions (i.e. rwx).

This post is simply a guide. Your values will differ depending on your desired outcome. In your case you may want to set only the group permissions or only the owner permissions (as opposed to both as illustrated in this post). The actual permission values you end up setting may differ too.

No comments:

Post a Comment