0

Based on the permission given below others can also read the file. I am logged in as ec2-user but I have to use sudo to read the file. Since permission is given for everyone to read why does it still ask sudo.

[ec2-user@ip-172-31-53-76 ~]$ sudo ls -la /var/log/nginx/access.log
-rw-rw-r-- 1 nginx root 22731 Sep  2 23:55 /var/log/nginx/access.log

permission of each of the folders

drwxr-xr-x  19 root root  269 Aug 26 00:52 var
drwxr-xr-x  9 root root 4096 Sep  3 03:19 log
drwxrwxr--  2 nginx root 159 Sep  3 03:19 nginx

What would I have to do so that I can run tail -n 10 /var/log/nginx/access.log without having to use sudo.

Krackout
  • 2,480
  • 9
  • 25
kumar
  • 183
  • 1
  • 1
  • 4
  • 1
    `drwxrwxr--` no `x` permission on directory for others, so you can't enter that directory – muru Sep 03 '20 at 08:41
  • 2
    Does this answer your question? [Execute vs Read bit. How do directory permissions in Linux work?](https://unix.stackexchange.com/questions/21251/execute-vs-read-bit-how-do-directory-permissions-in-linux-work) – muru Sep 03 '20 at 08:42

1 Answers1

0

As Muru suggested, you only need chmod o+x /var/log/nginx and you should be able to tail the file using any user. If you want just a certain user to be able to access it, you can use ACLs.

Krackout
  • 2,480
  • 9
  • 25