Ubuntu – Folder permission issue

bashcommand linedirectorypermissions

Kindly do not consider this as duplicate.
I have created a folder as root in the directory /tmp/test/ as well as some subfolders too.
I have changed the permission to read and write for all the users and groups, including the root.

$ sudo chmod -R 666 /tmp/test/

on issuing the
$ ls -l /tmp/test/
ls: cannot access '/tmp/test/db': Permission denied
ls: cannot access '/tmp/test/sp': Permission denied
total 0
d????????? ? ? ? ? ? db
d????????? ? ? ? ? ? sp

I get like this, Here I am unable to create a new file or directory.

$ printf 'test' >/tmp/test/sp/test

bash: /tmp/test/sp/test: Permission denied
It sounds confusing to me.

Best Answer

Directories require the executable flag, so try sudo chmod -R 776 /tmp/test.

Linux/Unix requires the execute bit in order for the user to enter a directory and access its contents, this includes listing what is inside it. Directory execute flags behave differently than a file's read flag.

Files within can be 666 however.

Related Question