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
Add group nginx to your user... usermod -G nginx,... username (Where .... Is any other groups you're a member of, not counting your primary group) On Fri, May 3, 2019, 3:03 PM Bee.Lists <bee.lists at gmail.com> 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 > > > > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos >
Just did that, and I still can?t do this: $ cd /var/log/nginx -bash: cd: /var/log/nginx: Permission denied> On May 3, 2019, at 7:22 PM, John Pierce <jhn.pierce at gmail.com> wrote: > > Add group nginx to your user... usermod -G nginx,... username > (Where .... Is any other groups you're a member of, not counting your > primary group)Cheers, Bee
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.