Wednesday, September 19, 2018

apache 2.2 - Set default permissions for new files (Linux)



I'm having a bit of a nightmare with file permissions on my web-server at the moment.




The server has Apache installed on it, which uses the user 'apache' from the group 'apache'.
I have also installed FTP which uses the user 'ftp' from the group 'ftp'.



The 'ftp' user has access to a directory on the server called 'uploads'. This is owned by the 'ftp' user and the group 'ftp'. This is all working fine.



The problem...



There are scripts owned by the 'apache' user which needs to have RWX access to the same directory, 'uploads'.
To try and achieve this I added the 'apache' user into the 'ftp' group and set the folder permissions to 775. This worked fine, but new files added by the 'ftp' user are always 744, allowing the 'ftp' users full access but only allowing the 'apache' user read access.




What I am looking for is the ability to always allow the 'apache' user RWX access to ALL files / folders in this directory. How do I set the default permissions for new files/folders to have a different permission? Or allow the group permissions to be RWX by default. Or have I missed something obvious??



Any help will be greatly received.
Thanks, Ben


Answer



You should try umask :




The umask (UNIX shorthand for "user file-creation mode mask") is a four-digit octal number that UNIX uses to determine the file permission for newly created files.





More information on the man page.



You can read this tutorial to understand how to use umask easily :


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...