"stat" says "permission denied", even though all the permissions are in place
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.
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
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?