Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

unix

chmod

ubuntu

I am trying to recursively change the permission of directories and sub-directories for "data" directory and running into following error..can someone provide inputs on the below error?

<username:/local/mnt/workspace/data>chmod -R 0644 . chmod: cannot read directory `.': Permission denied 
like image 766
carte blanche Avatar asked Apr 04 '13 00:04

carte blanche


People also ask

How do I fix permission denied chmod?

Every Linux user should know the quick fix for the “permission denied” error encountered while executing any shell script. “chmod” command resolves this issue by changing the script's file permissions and allowing it to in an executable format for the current user.

How do I fix permissions denied?

Resolve Permission Denied Error in Linux. To fix the permission denied error in Linux, one needs to change the file permission of the script. Use the “chmod” (change mode) command for this purpose. But before that, check the file permission.

Why do I get permission denied in terminal Linux?

While using Linux, you may encounter the error, “permission denied”. This error occurs when the user does not have the privileges to make edits to a file. Root has access to all files and folders and can make any edits. Other users, however, may not be allowed to make such edits.

How do I get permission to denied a folder in Linux?

Only a root user or user with sudo access can change the permissions for the file or directory you want to access or execute. If you are the correct user to make the required permission changes, you can run the “chmod” command and add the desired permission.


1 Answers

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.

like image 143
David W. Avatar answered Oct 07 '22 06:10

David W.