Home » Misc » Find out 777…

Find out 777 folders and change permissions

For some reason, the dropbox I am using occasionally loses permissions on some folders, which becomes 777. The following command can be used to change all folders with 777 permission to some other permissions.

find ./ -type d -perm 777 -print0 | xargs -0 chmod 755

The following (from man xargs) explains the options -print0 and -0.

Because Unix filenames can contain blanks and newlines, this default behaviour is often problematic; filenames containing blanks and/or newlines are incorrectly processed by xargs. In these situations it is better to use the -0 option, which prevents such problems. When using this option you will need to ensure that the program which produces the input for xargs also uses a null character as a separator. If that program is GNU find for example, the -print0 option does this for you.