Why can't I access my own folder with permission 644?

I can’t access a WordPress folder that was created with my user and with permission 644. Is it correct? When I try to access the folder I have this result:

mdm-suporte@localhost:~$ cd public_html/ -bash: cd: public_html/: Permission denied 

Also Apache results 403 error. Only with permission 755 I can access the folder and apache works.

Any thing wrong?

1

2 Answers

Folders must be executable to be accessed. Observe:

With 644 permissions on the directory:

[Mjolnir:~]mkdir test [Mjolnir:~]chmod 644 test [Mjolnir:~]ls -l | grep test drw-r--r-- 2 USER USER 4096 Jun 1 15:03 test/ [Mjolnir:~]ls -l test ls: cannot access 'test/.': Permission denied ls: cannot access 'test/..': Permission denied total 0 d????????? ? ? ? ? ? ./ d????????? ? ? ? ? ? ../ [Mjolnir:~]cd test -bash: cd: test: Permission denied 

With 755 permissions on the same directory:

[Mjolnir:~]chmod 755 test [Mjolnir:~]ls -l | grep test drwxr-xr-x 2 USER USER 4096 Jun 1 15:03 test/ [Mjolnir:~]ls -l test total 8 drwxr-xr-x 2 USER USER 4096 Jun 1 15:03 ./ drwxr-xr-x 57 USER USER 4096 Jun 1 15:04 ../ [Mjolnir:~]cd test [Mjolnir:test] 

The "execute" flag on directory gives accesses to filesystem objects under the directory. The "read" flags gives access to directory contents. So starting with:

test ├── file1 └── file2 

If you remove the execute flag, you can still list the contents:

>chmod -x test > echo test/* test/file1 test/file2 

but you cannot access the contents:

>cat test/file1 cat: test/file1: Permission denied 

You can't even get information on these files since this is done by accessing their inode, which is what the lack of execution privileges prevents you to do:

stat test/file1 stat: cannot stat 'test/file1': Permission denied 

Now, if you keep the execution privilege, but remove the red privilege, the situtation is the opposite:

>chmod +x-r test 

You cannot list the directory contents:

>ls test ls: cannot open directory 'test': Permission denied 

But if you know what it contains, you can access the corresponding inodes:

>stat test/file1 File: 'test/file1' Size: 6 Blocks: 8 IO Block: 4096 regular file Device: fd01h/64769d Inode: 24642501 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ me) Gid: ( 1000/ me) Access: 2019-06-01 09:07:30.300676842 +0200 Modify: 2019-06-01 08:53:14.811834525 +0200 Change: 2019-06-01 08:53:14.811834525 +0200 

And so access the contents:

>cat test/file1 File1 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like