Reputation: 40134
I have a need to make some folders/files (recursive) have the same permissions as that of the user. So:
How can I do so? Perhaps a little secret command I do know of?
If there is no easy way then perhaps I would need to create a loop and test/assign. Ultimately I only need to deal with 3 types:
Folders should be 777, most files 666, executables 777.
Upvotes: 1
Views: 222
Reputation: 295687
find
can do the work of finding files with a given permission set and running the smallest possible number of chmod
invocations necessary to cover them.
find . \
'(' -perm -0700 -exec chmod 0777 '{}' + ')' -o \
'(' -perm -0600 -exec chmod 0666 '{}' + ')'
Upvotes: 2
Reputation: 43039
There is no command that does for you. You do need a little loop:
for file in $(find . -print)
do
if [ -d $file -o -x $file ]; then
chmod 777 $file
else
chmod 666 $file
fi
done
Upvotes: -1