How to set up default group permission in linux folder
I have website folder called
/home/john/public_html
Now i want that what ever files are copied to that public_html or new files created inside that folder then those files should have default read /write permission by john , no matter who is the owner of that file.
Also i will be copying /creating files /directories by FTP , will that system work there as well or file with ftp won't have group read /write permission
i mean will umask work only files created / copied within shell or even outside shell aswell
You can achieve this using ACL. Look at the man page of setfacl/getfacl for details.
Unfortunately the syntax is a bit complex. Try something like:
setfacl -s u::rwx,g::r-x,o::r-x,m:rwx,u:john:rwx,d:u:john:rwx /home/john/public_html
Well, umask will still aply to newly created files, but you can "override" umask as well using ACL:
setfacl -s u::rwx,g::r-x,o::r-x,m:rwx,u:john:rwx,d:u:john:rwx,d:u::rwx,d:g::r-x,d:o::r-x,d:m:rwx /home/john/public_html
I'm not exactly sure what you're trying to accomplish, but it looks like it could be solved with group permissions and a setgid bit on the directory.
chown john.john-contrib /home/john/public_html chmod 2775 /home/john/public_html
Then when people create files, they'll be owned by the group 'john-contrib'. Everyone needs to be a member of john-contrib to put files in John's directory though.
If you really want everyone to write into John's directory all the time without any security controls... then chmod 2777 would work, but that's a little insane application of the /home filesystem.