Add read permissions to all the directories of a path

32,045

Solution 1

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!

Solution 2

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.

Solution 3

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

Share:
32,045

Related videos on Youtube

Jorge Vega Sánchez
Author by

Jorge Vega Sánchez

Updated on September 18, 2022

Comments

  • Jorge Vega Sánchez
    Jorge Vega Sánchez over 1 year

    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.

    • fedorqui
      fedorqui over 10 years
      chmod +r -R /your/path should make it. What error do you get?
  • Jorge Vega Sánchez
    Jorge Vega Sánchez over 10 years
    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.