Add read permissions to all the directories of a path

4

2

I want to add (not modify other file permissions) for all the directories in the path written bellow. Something like chmod -R xx4 /home/mDB/admin/KNUCKLES/dbs/

The path

/home/mDB/admin/KNUCKLES/dbs/

I try with this command i found in a forum but doesn't work for me.

chmod +r /home/mDB/admin/KNUCKLES/dbs/ -R

I only want to change the permissions for all the users not for the file/directory owner or the groups.

Thanks in advance.

Jorge Vega Sánchez

Posted 2013-10-03T12:48:15.387

Reputation: 165

2chmod +r -R /your/path should make it. What error do you get? – fedorqui – 2013-10-03T12:52:18.530

Answers

4

You can say:

chmod -R o+r /home/mDB/admin/KNUCKLES/dbs/

This would give read permission recursively to others, i.e. not owner/group.

EDIT: As per your comment, it seems that permissions for directories is the issue and not that of files. You could say:

chmod o+rx /home/mDB/{admin,admin/KNUCKLES,admin/KNUCKLES/dbs}

Note that since these are directories, you need to set the execute x bit on. Without that, r would serve no purpose!

devnull

Posted 2013-10-03T12:48:15.387

Reputation: 2 987

Sorry, i think my explanation is not so clear. I want to add read permissions for the folders /admin, KNUCKLES and dbs not all the folders inside dbs. – Jorge Vega Sánchez – 2013-10-04T14:49:18.960

@JorgeVegaSánchez See the edit above. – devnull – 2013-10-05T06:25:52.507

3

You'll have to split it up and issue multiple commands.

chmod -R xx4 /home/
chmod -R xx4 /home/mDB/
chmod -R xx4 /home/mDB/admin/
chmod -R xx4 /home/mDB/admin/KNUCKLES/
chmod -R xx4 /home/mDB/admin/KNUCKLES/dbs/

Someone with more advanced command-line-fu than me may know a shorter way.

LawrenceC

Posted 2013-10-03T12:48:15.387

Reputation: 63 487

Ok, there is no only a command to do that task. Thanks for your answer. – Jorge Vega Sánchez – 2013-10-04T14:45:44.723

0

To set the execute bit only for directories, do the following:

chmod -R a+X dir

From man chmod:

execute/search only if the file is a directory or already has execute permission for some user (X)

Answer from: https://unix.stackexchange.com/questions/39761/execute-bit-on-directories-but-not-files

Jonathan

Posted 2013-10-03T12:48:15.387

Reputation: 148