When I write ls -la o the command line, I get this output:
ls -la /var/log/nginx
d????????? ? ? ? ?            ? .
d????????? ? ? ? ?            ? ..
-????????? ? ? ? ?            ? access.log
for all files in this folder.
When I do it for another folder:
ls -la /var/log/nginx_back/
drwxr-xr-x  2 root root       4096 Апр 25 11:06 .
drwxrwxr-x 15 root ssh        4096 Май  1 00:29 ..    
-rw-r--r--  1 root root  220793880 Апр 25 11:04 access.log-20170401.gz
Everything is ok.
Permissions on the directory above:
drw-r--r--  2 nginx     adm        69632 Май  1 00:29 nginx    
drwxr-xr-x  2 root      root        4096 Апр 25 11:06 nginx_back
I have these question marks only when I'm not root.
I've added my user to the group nginx, added all permissions, created another user, but the system doesn't want to show the file's attributes for non-superusers in the directory /var/log/nginx.
Why is that?
This issue is a permission problem. Specifically, it relates to execute bits on directories.
Consider the following example
$ mkdir -p remove_execute/remove_execute_test     
$ touch remove_execute/remove_execute_test/test_file.txt 
$ ls -la remove_execute/remove_execute_test/ 
total 8 
drwxrwxr-x 2 zerodf zerodf 4096 Nov 21 10:51 . 
drwxrwxr-x 3 zerodf zerodf 4096 Nov 21 10:51 ..
-rw-rw-r-- 1 zerodf zerodf    0 Nov 21 10:51 test_file.txt
Now, if we remove execute permission on the directory, we can't get the stats.
$ sudo chmod a-x remove_execute/remove_execute_test/ 
$ ls -la remove_execute/remove_execute_test/ 
ls: cannot access remove_execute/remove_execute_test/..: Permission denied 
ls: cannot access remove_execute/remove_execute_test/test_file.txt: Permission denied 
ls: cannot access remove_execute/remove_execute_test/.: Permission         denied 
total 0 
d????????? ? ? ? ?            ? . 
d????????? ? ? ? ?            ? ..
-????????? ? ? ? ?            ? test_file.txt
Unless we have root permissions.
$ sudo ls -la remove_execute/remove_execute_test/
total 8
drw-rw-r-- 2 zerodf zerodf 4096 Nov 21 10:51 .
drwxrwxr-x 3 zerodf zerodf 4096 Nov 21 10:51 ..
-rw-rw-r-- 1 zerodf zerodf    0 Nov 21 10:51 test_file.txt
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With