-2

i want every directory permission set to 755. So i want to change any directories having permission other 755 to 755. How can i change this without even touching the directories which is already set to 755 permission.
I'm using Ubuntu.

1

3 Answers 3

2

Note that you probably don't want to do this (and you definitely don't want to do this on system directories) but if you're sure then

find /path -type d ! -perm 755

will find all of the directories in /path that don't have 755 as a perm

After reviewing the list then

find /path -type d ! -perm 755 -exec chmod 755 {} +

should do what you want.

5
  • I think that the syntax is not quite logical. E.g Directories having permissions 777 will also be getting perms 755. Jan 15, 2013 at 8:41
  • i'm making the changes in my usb drive not in system files..thank you for the answer
    – Guruji
    Jan 15, 2013 at 8:44
  • do you have any other answer val0x00ff..
    – Guruji
    Jan 15, 2013 at 8:45
  • @val0x00ff: That's exactly what the OP appears to have asked for isn't it - all directories not currently 755 set to 755 ?
    – user9517
    Jan 15, 2013 at 8:52
  • @lain I probably misread the question. But if all directories(regardless their current permission status) are to be 755 then the syntax is of course correct. The question still has to be re-articulated. Jan 15, 2013 at 8:59
1

find . -type d -not -perm 0755 -exec chmod 0755 '{}' \; should help you !

1

You simplay can run find and change directories to 755. Example below

find /path/to/dir -type d ! -perm 755 -exec chmod 755 {} \;

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .