On 4/5/19 8:03 am, Bee.Lists wrote:
Hi folks.
Just wondering if I can change the ownership on the nginx logs folder so I can access them easier for analysis on a regular basis and cronjobs.
/var/log/nginx is owned by nginx:nginx which shuts me out.
Cheers, Bee
Here's a twist to the other provided solutions. I find it easier to leave permissions as they are and instead use ACL's. That way, I can remove the ACL's (# sudo setfacl -b /path/to/dir) and not worry about what the original permissions were.
This is how I'd sort it out:
First, I'd create a default ACL (this will allow new files in the directory to inherit the ACL): # sudo setfacl -d -m u:<your_user_name>:rwx /var/log/nginx
Next, I'dd apply the ACL to the directory: # sudo setfacl -m u:<your_user_name>:rwx /var/log/nginx
Finally, I'd ensure that I can access existing files in that directory: # sudo sh -c "find /var/log/nginx -maxdepth 1 -type f -exec setfacl -m u:<your_user_name>:r {} ;"
Caveat: I use EXT4 so not sure how this would play with other file systems.