Why do I need the x permission to cd into a directory? [duplicate]

ls -la prints the following:

drwxrwxrw- 2 www-data www-data 4096 Aug 12 11:04 files

My username does not belong to www-data. When trying to cd into files I get a "permission denied" though the "read" permission for others is set.

Why do I need the "execute" permission?


The meaning of execute permission for a directory is the ability to look up file names inside that directory.

Without execute permission on the directory, you can't stat, open, rename, delete, or descend into subdirectories inside that directory.

The only thing you can do is see the list of which filenames exist, and then only if you have read permission (and read but not execute is a strange set of permissions to have for a directory).

If you are not owner of the given directory, become a owner by using,

sudo chown username /path/to/directory

Or better way is to add user to a group,

sudo usermod -a -G groupName userName

for getting execute permission use,

sudo chmod a+x /path/to/dir