I have this:

ls -al /home/my_user/dir1/dir2/file1.txt
-rwxr-xr-x 1 http http 2798 Dec 30 18:18 /home/my_user/dir1/dir2/file1.txt

However, I can't stat it:

sudo -u http stat /home/my_user/dir1/dir2/file1.txt
stat: cannot stat '/home/my_user/dir1/dir2/file1.txt': Permission denied

Why? How to fix that without having to chmod 777 <path>, is there more approprivate way


  • Check the permissions of all the containing directories. – Michael Hampton Dec 30 '18 at 21:22

I think you need to verify the permissions of each folder involved in the path before you get to the file itself.

Many Linux distributions default the permissions to (0700) (meaning just the user itself is allow to read/write/execute), to each folder inside the /home directory, which means that if user my_user has a file /home/my_user/dir1/dir2/file1.txt with the permissions 0755 the user http can't stat it because the default permissions I mentioned above will prevent it.

My guess is that when you executed the ls -al /home/my_user/dir1/dir2/file1.txt was with a user other than http and that user could actually read the file. If that is the case, you have to correct the permissions on all the directories with tools like chmod or setfacl if you want to be more specific.

I hope this helps.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.