21

This question already has an answer here:

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?

marked as duplicate by heemayl, Ron, karel, Braiam, Eric Carvalho Aug 13 '15 at 0:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

28

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
  • 1
    ... or add your user to the group. – Jos Aug 12 '15 at 9:27
  • 5
    Changing the owner of files or folders belonging to "www-data" is probably not a good idea. Your webserver will not be able to read the files any more. – Twinkles Aug 12 '15 at 11:15
  • 2
    Have to mention though that merely adding the user to the group won't change permissions of currently running processes. You should either login as yourself again in terminal (i.e. su $(whoami)) to have these rights for this terminal session, or logout of the whole system and re-login to have this take effect for all your apps. – Ruslan Aug 12 '15 at 13:02
  • 4
    Actually the meaning of execute permission is the ability to traverse the directory. For instance, even if you have execute (and read) permission on a directory you are still not allowed to look up file names in it if a higher directory does not grant you execute permission. – Pepijn Schmitz Aug 12 '15 at 13:12
  • 1
    "The meaning of execute permission for a directory is the ability to look up file names inside that directory.", no, that's what the read permission is for. The execute permission on a directory is for the ability to go into it (or use anything in it). – Bruno Aug 12 '15 at 17:23

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