chmod: cannot read directory `.': Permission denied [closed] chmod: cannot read directory `.': Permission denied [closed] unix unix

chmod: cannot read directory `.': Permission denied [closed]


Directories need the execute permission set in order to see their contents.

From http://content.hccfl.edu/pollock/AUnix1/FilePermissions.htm

You can think of read and execute on directories this way: directories are data files that hold two pieces of information for each file within, the file's name and it's inode number. Read permission is needed to access the names of files in a directory. Execute (a.k.a. search) permission is needed to access the inodes of files in a directory, if you already know the file's name.

When you change a directory permission to 644, you are unable to read the files in that directory although you can read that directory to see it exists.

You need to do this:

$ chmod -R 0755 .

A better way might be to use string permission if you simply want to turn off

Otherwise, you can see the directory, but not access the information in that directory.

You maybe better off using relative permissions instead of absolute permissions:

$ chmod -R go-w .

Will remove write permission from group and other, but not touch execute permission.

You can also use find just to set the directories or just to set files:

$ find . -type d -exec chmod 755 {} \;

This will only touch directories, setting read and execute permission on all directories and setting write permission for the owner. This way, you're not setting execute permission on files themselves.


I would guess that since you are using recursion that you are trying to CD to a directory that does not have execute permission for you.